Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
7bf9561534 |
374
build.gradle
374
build.gradle
|
@ -1,251 +1,123 @@
|
|||
import groovy.json.JsonOutput
|
||||
|
||||
def mainVersion = "1.7"
|
||||
def buildNumber = "38"
|
||||
|
||||
// For those who want the bleeding edge
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
apply plugin: 'idea'
|
||||
|
||||
/*
|
||||
// for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot
|
||||
plugins {
|
||||
id "net.minecraftforge.gradle.forge" version "2.0.2"
|
||||
}
|
||||
*/
|
||||
version = "${mainVersion}-${buildNumber}"
|
||||
group= "malte0811"
|
||||
archivesBaseName = "IndustrialWires"
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = "1.12.2-14.23.5.2847"
|
||||
runDir = "run"
|
||||
|
||||
replace '${version}', project.version
|
||||
mappings = "stable_39"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name 'ic2'
|
||||
url 'http://maven.ic2.player.to/'
|
||||
}
|
||||
maven {
|
||||
name 'tr'
|
||||
url 'http://maven.modmuss50.me'
|
||||
}
|
||||
maven {
|
||||
name 'jared maven'
|
||||
url 'http://blamejared.com/maven'
|
||||
}
|
||||
maven { // Albedo/Mirage Lights
|
||||
url 'https://repo.elytradev.com/'
|
||||
}
|
||||
maven { // JEI & Tinkers
|
||||
name 'DVS1 Maven FS'
|
||||
url 'http://dvs1.progwml6.com/files/maven'
|
||||
}
|
||||
// dependencies of TR...
|
||||
maven {
|
||||
|
||||
url 'http://maven.mcmoddev.com'
|
||||
}
|
||||
maven {
|
||||
// HWYLA
|
||||
name "TehNut"
|
||||
url "http://tehnut.info/maven/"
|
||||
}
|
||||
repositories {//Curseforge maven for project red
|
||||
maven {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "chickenbones"
|
||||
url = "http://chickenbones.net/maven"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'net.industrial-craft:industrialcraft-2:2.8.+'
|
||||
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+"
|
||||
compileOnly "pl.asie.charset:charset:0.5.6.4.19:full"
|
||||
//Project red and runtime dependencies
|
||||
compileOnly "project-red-base:ProjectRed-1.12.2:4.9.1.92:Base"
|
||||
//runtime "project-red-integration:ProjectRed-1.12.2:4.9.1.92:integration"
|
||||
//runtime "forge-multipart-cbe:ForgeMultipart-1.12.2:2.5.0.69:universal"
|
||||
//runtime "codechicken:CodeChickenLib:1.12.2-3.2.1.349:universal"
|
||||
//runtime "codechicken:ChickenASM:1.12-1.0.2.7"
|
||||
//runtime "mrtjpcore:MrTJPCore-1.12.2:2.1.3.35:universal"
|
||||
//Tech Reborn
|
||||
compileOnly "TechReborn:TechReborn-1.12:2.6.9.7:universal"
|
||||
compileOnly "RebornCore:RebornCore-1.12:3.2.+:universal"
|
||||
//Others
|
||||
//TODO do something about this
|
||||
// compileOnly 'com.elytradev:mirage:2.0.1-SNAPSHOT'
|
||||
compileOnly "mezz.jei:jei_1.12:4.+"
|
||||
compileOnly "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.8.460"
|
||||
compile 'com.elytradev:mirage:2.0.3-rc3-SNAPSHOT'
|
||||
compile "gregtechce:gregtech:1.12.2:1.9.0.481"
|
||||
compile "magneticraft:Magneticraft_1.12:2.8.2:dev"
|
||||
|
||||
}
|
||||
|
||||
jar {
|
||||
from 'LICENSE'
|
||||
manifest {
|
||||
attributes 'Maven-Artifact': group+':'+archivesBaseName+':'+version
|
||||
attributes "FMLAT": "industrialwires_at.cfg"
|
||||
}
|
||||
}
|
||||
|
||||
task signMain(type: SignJar) {
|
||||
onlyIf {
|
||||
project.hasProperty('keyStore')
|
||||
}
|
||||
dependsOn reobfJar
|
||||
if (project.hasProperty('keyStore')) {
|
||||
keyStore = project.keyStore
|
||||
alias = project.storeAlias
|
||||
storePass = project.storePass
|
||||
keyPass = project.storePass
|
||||
inputFile = jar.archivePath
|
||||
outputFile = jar.archivePath
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn signMain
|
||||
|
||||
processResources
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
|
||||
//Code for automatic update JSON generation
|
||||
class GenerateUpdateJSON extends DefaultTask {
|
||||
static def IW_VERSION_PREFIX = "####Version "
|
||||
static def MC_VERSION_PREFIX = "###Minecraft "
|
||||
static def UNFINISHED_SUFFIX = " - UNFINISHED"
|
||||
static def RECOMMENDED = "-recommended"
|
||||
static def LATEST = "-latest"
|
||||
static def CF_URL = "https://minecraft.curseforge.com/projects/industrial-wires"
|
||||
|
||||
int compareVersions(String vA, String vB) {
|
||||
String[] vPartsA = vA.split("[\\D]")
|
||||
String[] vPartsB = vB.split("[\\D]")
|
||||
if (vPartsA.length==0&&vPartsB.length==0)
|
||||
return vA <=> vB
|
||||
else if (vPartsA.length==0)
|
||||
return -1
|
||||
else if (vPartsB.length==0)
|
||||
return 1
|
||||
|
||||
int length = Math.min(vPartsA.length, vPartsB.length)
|
||||
for (int i = 0;i<length;i++) {
|
||||
int pA = Integer.parseInt(vPartsA[i])
|
||||
int pB = Integer.parseInt(vPartsB[i])
|
||||
if (pA!=pB) {
|
||||
return pA<=>pB
|
||||
}
|
||||
}
|
||||
if (vPartsA.length != vPartsB.length)
|
||||
return vPartsA.length <=> vPartsB.length
|
||||
return vA <=> vB
|
||||
}
|
||||
|
||||
def addChangelog(Map<String, Map<String, String>> changelogForVersions, Map<String, String> promos,
|
||||
String currentMCVersion, String currentVersion, String currentChangelog) {
|
||||
if (!changelogForVersions.containsKey(currentMCVersion)) {
|
||||
promos.put(currentMCVersion+RECOMMENDED, currentVersion)
|
||||
promos.put(currentMCVersion+LATEST, currentVersion)
|
||||
changelogForVersions[currentMCVersion] = new TreeMap<>({String s1, String s2->
|
||||
compareVersions(s1, s2)})
|
||||
}
|
||||
changelogForVersions[currentMCVersion][currentVersion] = currentChangelog
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
def generate() {
|
||||
File changelog = new File("changelog.md")
|
||||
if (!changelog.exists())
|
||||
println "Changelog does not exist! Aborting!"
|
||||
else {
|
||||
String currentMCVersion = "";
|
||||
Map<String, Map<String, String>> changelogForVersions = new HashMap<>()
|
||||
Map<String, String> promos = new TreeMap<>({String s1, String s2->
|
||||
compareVersions(s1, s2)})
|
||||
String currentVersion = null
|
||||
String currentChangelog = ""
|
||||
changelog.eachLine {line ->
|
||||
if (line.startsWith(IW_VERSION_PREFIX)) {
|
||||
if (currentVersion!=null) {
|
||||
addChangelog(changelogForVersions, promos, currentMCVersion, currentVersion, currentChangelog)
|
||||
}
|
||||
if (!line.endsWith(UNFINISHED_SUFFIX)) {
|
||||
currentVersion = line.substring(IW_VERSION_PREFIX.length())
|
||||
} else {
|
||||
currentVersion = (String) null
|
||||
}
|
||||
currentChangelog = ""
|
||||
} else if (line.startsWith(MC_VERSION_PREFIX)) {
|
||||
if (currentVersion!=null) {
|
||||
addChangelog(changelogForVersions, promos, currentMCVersion, currentVersion, currentChangelog)
|
||||
}
|
||||
currentChangelog = ""
|
||||
currentVersion = (String) null
|
||||
currentMCVersion = line.substring(MC_VERSION_PREFIX.length())
|
||||
} else if (!line.isEmpty()) {
|
||||
if (currentChangelog.length()==0)
|
||||
currentChangelog += line
|
||||
else
|
||||
currentChangelog += "\n"+line
|
||||
}
|
||||
}
|
||||
Map<String, Object> mainMap = new TreeMap<>({String s1, String s2->
|
||||
compareVersions(s1, s2)})
|
||||
mainMap.putAll(changelogForVersions)
|
||||
mainMap["homepage"] = CF_URL
|
||||
mainMap["promos"] = promos
|
||||
def outJson = JsonOutput.toJson(mainMap)
|
||||
outJson = JsonOutput.prettyPrint(outJson)
|
||||
File outF = new File("changelog.json")
|
||||
outF.delete()
|
||||
outF << outJson
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task updateJson(type: GenerateUpdateJSON)
|
||||
|
||||
build.finalizedBy updateJson
|
||||
def mainVersion = "1.6"
|
||||
def buildNumber = "22"
|
||||
|
||||
// For those who want the bleeding edge
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
|
||||
/*
|
||||
// for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot
|
||||
plugins {
|
||||
id "net.minecraftforge.gradle.forge" version "2.0.2"
|
||||
}
|
||||
*/
|
||||
version = "${mainVersion}-${buildNumber}"
|
||||
group= "malte0811"
|
||||
archivesBaseName = "IndustrialWires"
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = "14.22.1.2479"
|
||||
runDir = "run"
|
||||
|
||||
replace '${version}', project.version
|
||||
mappings = "snapshot_20170628"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name 'ic2'
|
||||
url 'http://maven.ic2.player.to/'
|
||||
}
|
||||
maven {
|
||||
name 'tr'
|
||||
url 'http://maven.modmuss50.me'
|
||||
}
|
||||
maven {
|
||||
name 'jared maven'
|
||||
url 'http://blamejared.com/maven'
|
||||
}
|
||||
maven { // Albedo/Mirage Lights
|
||||
url 'https://repo.elytradev.com/'
|
||||
}
|
||||
maven { // JEI & Tinkers
|
||||
name 'DVS1 Maven FS'
|
||||
url 'http://dvs1.progwml6.com/files/maven'
|
||||
}
|
||||
// dependencies of TR...
|
||||
maven {
|
||||
url 'http://maven.epoxide.xyz'
|
||||
}
|
||||
maven {
|
||||
// HWYLA
|
||||
name "TehNut"
|
||||
url "http://tehnut.info/maven/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile 'net.industrial-craft:industrialcraft-2:2.8.+'
|
||||
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+:deobf"
|
||||
compileOnly "TechReborn:TechReborn-1.12:2.6.+:dev"
|
||||
compileOnly "RebornCore:RebornCore-1.12:3.2.+:dev"
|
||||
deobfCompile 'com.elytradev:mirage:2.0.1-SNAPSHOT'
|
||||
compileOnly "mezz.jei:jei_1.12:4.+"
|
||||
compileOnly "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.+"
|
||||
}
|
||||
|
||||
jar {
|
||||
from 'LICENSE'
|
||||
manifest {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
task signMain(type: SignJar) {
|
||||
onlyIf {
|
||||
project.hasProperty('keyStore')
|
||||
}
|
||||
dependsOn reobfJar
|
||||
if (project.hasProperty('keyStore')) {
|
||||
keyStore = project.keyStore
|
||||
alias = project.storeAlias
|
||||
storePass = project.storePass
|
||||
keyPass = project.storePass
|
||||
inputFile = jar.archivePath
|
||||
outputFile = jar.archivePath
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn signMain
|
||||
|
||||
processResources
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
{
|
||||
"homepage": "https://minecraft.curseforge.com/projects/industrial-wires",
|
||||
"promos": {
|
||||
"1.10.2-latest": "1.4-18",
|
||||
"1.10.2-recommended": "1.4-18",
|
||||
"1.11.2-latest": "1.5-19",
|
||||
"1.11.2-recommended": "1.5-19",
|
||||
"1.12.2-latest": "1.7-36",
|
||||
"1.12.2-recommended": "1.7-36"
|
||||
},
|
||||
"1.10.2": {
|
||||
"1.1-3": " - fixed incompatibility with IE build 48\n - reduced the amount of calls to core IE classes to make such incompatibilities less likely\n - fixed localization of the creative tab",
|
||||
"1.1-4": " - fixed an insane amount of log-spam in an edgecase (probably a Vanilla or Forge bug)\n - added config values for wire length per connection and per coil item\n ",
|
||||
"1.2-5 (10,000 download celebratory release)": " - added mechanical converters and the rotational motor\n - they convert between IE rotational energy (windmill, dynamo etc) and IC2 kinetic energy\n - Rotational motor: produces IE rotational energy from IF\n - No lossless conversion\n - Can be disabled in the config\n - wire coils show when they are out of range (to match the behavior of IE coils in the latest dev version)",
|
||||
"1.2-6": " - reduced the discrepancies between IC2 cables and Industrial Wires\n - machines don't explode when they shouldn't except in some corner cases\n - potentially fixed missing textures on the mechanical converters\n - added Chinese translations (thanks SihenZhang)",
|
||||
"1.3-7": " - added Jacob's Ladders/High voltage travelling arcs\n - they don't have a particular purpose aside from looking nice",
|
||||
"1.3-8": " - the converters and the motor don't have missing textures any more when using Chisel",
|
||||
"1.4-9": " - added Control Panels\n - They can be used to control and monitor a lot of redstone signals from a few blocks",
|
||||
"1.4-10": " - added lock switches for control panels (backport from 1.11)\n - Can only be turned on by someone with the correct key to prevent unauthorized access\n - up to 10 keys can be added to a keyring to reduce inventory spam\n - IC2 items can be added to the appropriate sections of the engineers toolbox (backport from 1.11)\n - Components (lighted button, indicator light, etc.) on panels now actually light up (backport from 1.11)\n - Fixed power loss when no energy is being transmitted",
|
||||
"1.4-16": " - Backported a lot of fixes from 1.11 and 1.12",
|
||||
"1.4-18": " - Fixed a crash with SpongeForge, chunk loading issues without\n - Fixed some components resetting on chunk unload"
|
||||
},
|
||||
"1.11.2": {
|
||||
"1.5-11": " - Updated to Minecraft 1.11.2\n - Added Panel Meters to monitor a redstone signal with reasonable accuracy\n - Multiple components on the same panel network can modify the same signal now without causing undefined behavior\n - Lock Switches no longer break the model cache",
|
||||
"1.5-12": " - Added tilted control panels\n - Panels are no longer created from machine casings, there is a dedicated item for that now, the Unfinished Control Panel\n - Angle and height can be configured in the Engineer's Workbench\n - Fixed a CME when multi-threaded chunk rendering is enabled\n - Fixed control panels not connecting or disconnecting properly when a panel connector between the panel and the RS controller is broken/placed\n - Improved the performance of the control panel hitbox rendering",
|
||||
"1.5-13": " - Labels no longer break the model cache and cause lag\n - Labels don't break on dedicated servers any more",
|
||||
"1.5-17": " - Backported some fixes from 1.12",
|
||||
"1.5-19": " - Fixed a crash with SpongeForge, chunk loading issues without\n - Fixed some components resetting on chunk unload"
|
||||
},
|
||||
"1.12.2": {
|
||||
"1.5-14": " - Updated to Minecraft 1.12\n - Added a recipe for the key ring. Kind of forgot about adding one when I added the ring itself...\n - Fixed wire length crafting leaving wrong coils when the output has maximum length\n - Fixed some more connection issues with control panels",
|
||||
"1.5-15": " - Components can be placed in the world now to use the as conventional levers/etc.\n - Added documentation on the key ring. It also shows all attached keys on the tooltip now\n - Fixed some bugs with key ring crafting\n - Fixed control panels causing disconnects on servers",
|
||||
"1.6-20": " - Added the Marx Generator, an alternative ore processing method\n - Hearing protection absolutely required!\n - You may need to do some math and measurements for ore processing to work. It will kill entites just fine without any science\n - IC2 is no longer a hard dependency. The wires and converters will obviously be disabled without it\n - Vastly improved snapping in the panel creator\n - Added some Mirage (Albedo) compat\n - IW is signed now!\n - Analog panel components can interact with 2 channels now, rough and fine control\n - Fixed GUI background and item tooltips\n - Fixed some components resetting when the chunk is unloaded\n - Chunks with control panels properly unload now",
|
||||
"1.6-21": " - Added shaders for the Marx generator and Jacob's ladder\n - Fixed wires connected to a Marx generator on a server being invisible\n - The Marx generator actually gives output when processing ores now. Oops...\n - The \"safe distance\" formulas for the Marx generator in the manual now match the real safe distance\n - Improved rendering of the Marx generator in the manual. Some of this is only enabled with maven build 275+ or official build 75+ (not released yet)",
|
||||
"1.6-22": " - Added a Seven-Segment display for control panels\n - Panel components update their values as soon as they are changed in the GUI\n - Fixed a crash when breaking a panel with buttons, locks or toggle switches on it under special circumstances\n - Fixed server crashes when using panel components with a second controller id, but no channel set\n - Fixed various NPE crashes with control panel models under heavy load\n - Fixed wrong panel component ordering with raytracing",
|
||||
"1.6-23": " - Added a command to allow taking screenshots of Marx generator discharges (/ciw triggermarxscreenshot)\n - Panel components have to be shift-clicked to place them in the world\n - Fixed wire coil crafting\n - Added a recipe for the Seven-Segment displays",
|
||||
"1.6-24": " - Fixed an infinite energy bug\n - Changed the default value for maximum energy conversion",
|
||||
"1.6-25": " - Updated to IE build 77\n - IC2 wires cause damage\n - Added insulated versions of gold, copper and tin wires. Due to heat sensitive insulation the transfer capacity is half of the normal capacity\n - Added feedthrough insulators for all IC2 wire types\n - Wire coils now automatically \"merge\" when picked up\n - Config values are applied to the game directly now",
|
||||
"1.7-26": " - Added Mechanical Multiblocks (energy storage and EU<->FE conversion)\n - There will be an explanation video for these once I have time to make one\n - Fixed the small mechanical converter blowing up tin wires\n - Fixed wires not joining their outputs correctly\n - Fixed wire connectors not breaking when the block they're on is broken",
|
||||
"1.7-27": " - Fixed panel components causing issues on dedicated servers\n - Added an automatic update checker (Using the Forge update JSON)",
|
||||
"1.7-28": " - Added the Redstone Controller: Others, it allows control panels to interface with Project:Red and Charset wires\n - Rewrote the control panel redstone code\n - Added localization for IW's multiblocks\n - Fixed issues with zero-length mechanical multiblocks",
|
||||
"1.7-29": " - The wires can now transmit FE as well as EU, but not both at once\n - Fixed the Marx generator not charging beyond a quite low voltage",
|
||||
"1.7-30": " - Fixed crashes when IC2 isn't installed\n - Fixed connectors allowing too much power output\n - Added a config option for some of the wires' properties\n - Updated chinese translation (thanks @DepletedPrism)",
|
||||
"1.7-31": " - Fixed accidental conversion from FE to EU\n - Fixed connectors not blowing up as intended\n ",
|
||||
"1.7-32": " - Fixed connectors not rendering properly without IC2\n - Fixed parts of the mechanical multiblocks not rendering when Optifine is installed\n - Changed some values for the mechanical multiblock sound",
|
||||
"1.7-33": " - Fixed the Marx generator not processing ores\n - Fixed control panels and the Marx generator not working when connected directly\n - Added Russian translation (thanks @StolenSoda)",
|
||||
"1.7-34": " - Control panels can use the texture of any block now\n - Added a recipe to copy the settings of an unfinished control panel\n - The Marx generator now returns the wires used in its construction when disassembled\n - Fixed the RS controller for non-IE wires not keeping its IO state on world reload\n - Fixed control panels not working correctly with multiple controllers",
|
||||
"1.7-35": " - Fixed a crash when placing certain items in the crafting grid",
|
||||
"1.7-36": " - Added an RGB indicator light, controlled by 3 (independent) RS signals\n - Fixed a bug allowing for unfinished control panels to be duplicated\n - Fixed insulated and uninsulated wire producing the same wire coils\n - Fixed some issues (including a crash) with the IE RS controller on dedicated servers"
|
||||
}
|
||||
}
|
134
changelog.md
134
changelog.md
|
@ -1,81 +1,4 @@
|
|||
###Minecraft 1.12.2
|
||||
|
||||
####Version 1.7-36
|
||||
- Added an RGB indicator light, controlled by 3 (independent) RS signals
|
||||
- Fixed a bug allowing for unfinished control panels to be duplicated
|
||||
- Fixed insulated and uninsulated wire producing the same wire coils
|
||||
- Fixed some issues (including a crash) with the IE RS controller on dedicated servers
|
||||
|
||||
####Version 1.7-35
|
||||
- Fixed a crash when placing certain items in the crafting grid
|
||||
|
||||
####Version 1.7-34
|
||||
- Control panels can use the texture of any block now
|
||||
- Added a recipe to copy the settings of an unfinished control panel
|
||||
- The Marx generator now returns the wires used in its construction when disassembled
|
||||
- Fixed the RS controller for non-IE wires not keeping its IO state on world reload
|
||||
- Fixed control panels not working correctly with multiple controllers
|
||||
|
||||
####Version 1.7-33
|
||||
- Fixed the Marx generator not processing ores
|
||||
- Fixed control panels and the Marx generator not working when connected directly
|
||||
- Added Russian translation (thanks @StolenSoda)
|
||||
|
||||
####Version 1.7-32
|
||||
- Fixed connectors not rendering properly without IC2
|
||||
- Fixed parts of the mechanical multiblocks not rendering when Optifine is installed
|
||||
- Changed some values for the mechanical multiblock sound
|
||||
|
||||
####Version 1.7-31
|
||||
- Fixed accidental conversion from FE to EU
|
||||
- Fixed connectors not blowing up as intended
|
||||
|
||||
####Version 1.7-30
|
||||
- Fixed crashes when IC2 isn't installed
|
||||
- Fixed connectors allowing too much power output
|
||||
- Added a config option for some of the wires' properties
|
||||
- Updated chinese translation (thanks @DepletedPrism)
|
||||
|
||||
####Version 1.7-29
|
||||
- The wires can now transmit FE as well as EU, but not both at once
|
||||
- Fixed the Marx generator not charging beyond a quite low voltage
|
||||
|
||||
####Version 1.7-28
|
||||
- Added the Redstone Controller: Others, it allows control panels to interface with Project:Red and Charset wires
|
||||
- Rewrote the control panel redstone code
|
||||
- Added localization for IW's multiblocks
|
||||
- Fixed issues with zero-length mechanical multiblocks
|
||||
|
||||
####Version 1.7-27
|
||||
- Fixed panel components causing issues on dedicated servers
|
||||
- Added an automatic update checker (Using the Forge update JSON)
|
||||
|
||||
####Version 1.7-26
|
||||
- Added Mechanical Multiblocks (energy storage and EU<->FE conversion)
|
||||
- There will be an explanation video for these once I have time to make one
|
||||
- Fixed the small mechanical converter blowing up tin wires
|
||||
- Fixed wires not joining their outputs correctly
|
||||
- Fixed wire connectors not breaking when the block they're on is broken
|
||||
|
||||
####Version 1.6-25
|
||||
- Updated to IE build 77
|
||||
- IC2 wires cause damage
|
||||
- Added insulated versions of gold, copper and tin wires. Due to heat sensitive insulation the transfer capacity is half of the normal capacity
|
||||
- Added feedthrough insulators for all IC2 wire types
|
||||
- Wire coils now automatically "merge" when picked up
|
||||
- Config values are applied to the game directly now
|
||||
|
||||
####Version 1.6-24
|
||||
- Fixed an infinite energy bug
|
||||
- Changed the default value for maximum energy conversion
|
||||
|
||||
####Version 1.6-23
|
||||
- Added a command to allow taking screenshots of Marx generator discharges (/ciw triggermarxscreenshot)
|
||||
- Panel components have to be shift-clicked to place them in the world
|
||||
- Fixed wire coil crafting
|
||||
- Added a recipe for the Seven-Segment displays
|
||||
|
||||
####Version 1.6-22
|
||||
#####Version 1.6-22
|
||||
- Added a Seven-Segment display for control panels
|
||||
- Panel components update their values as soon as they are changed in the GUI
|
||||
- Fixed a crash when breaking a panel with buttons, locks or toggle switches on it under special circumstances
|
||||
|
@ -83,14 +6,14 @@
|
|||
- Fixed various NPE crashes with control panel models under heavy load
|
||||
- Fixed wrong panel component ordering with raytracing
|
||||
|
||||
####Version 1.6-21
|
||||
#####Version 1.6-21
|
||||
- Added shaders for the Marx generator and Jacob's ladder
|
||||
- Fixed wires connected to a Marx generator on a server being invisible
|
||||
- The Marx generator actually gives output when processing ores now. Oops...
|
||||
- The "safe distance" formulas for the Marx generator in the manual now match the real safe distance
|
||||
- Improved rendering of the Marx generator in the manual. Some of this is only enabled with maven build 275+ or official build 75+ (not released yet)
|
||||
|
||||
####Version 1.6-20
|
||||
#####Version 1.6-20
|
||||
- Added the Marx Generator, an alternative ore processing method
|
||||
- Hearing protection absolutely required!
|
||||
- You may need to do some math and measurements for ore processing to work. It will kill entites just fine without any science
|
||||
|
@ -103,32 +26,23 @@
|
|||
- Fixed some components resetting when the chunk is unloaded
|
||||
- Chunks with control panels properly unload now
|
||||
|
||||
####Version 1.5-15
|
||||
#####Version 1.5-15
|
||||
- Components can be placed in the world now to use the as conventional levers/etc.
|
||||
- Added documentation on the key ring. It also shows all attached keys on the tooltip now
|
||||
- Fixed some bugs with key ring crafting
|
||||
- Fixed control panels causing disconnects on servers
|
||||
|
||||
####Version 1.5-14
|
||||
#####Version 1.5-14
|
||||
- Updated to Minecraft 1.12
|
||||
- Added a recipe for the key ring. Kind of forgot about adding one when I added the ring itself...
|
||||
- Fixed wire length crafting leaving wrong coils when the output has maximum length
|
||||
- Fixed some more connection issues with control panels
|
||||
|
||||
###Minecraft 1.11.2
|
||||
|
||||
####Version 1.5-19
|
||||
- Fixed a crash with SpongeForge, chunk loading issues without
|
||||
- Fixed some components resetting on chunk unload
|
||||
|
||||
####Version 1.5-17
|
||||
- Backported some fixes from 1.12
|
||||
|
||||
####Version 1.5-13
|
||||
#####Version 1.5-13
|
||||
- Labels no longer break the model cache and cause lag
|
||||
- Labels don't break on dedicated servers any more
|
||||
|
||||
####Version 1.5-12
|
||||
#####Version 1.5-12
|
||||
- Added tilted control panels
|
||||
- Panels are no longer created from machine casings, there is a dedicated item for that now, the Unfinished Control Panel
|
||||
- Angle and height can be configured in the Engineer's Workbench
|
||||
|
@ -136,48 +50,36 @@
|
|||
- Fixed control panels not connecting or disconnecting properly when a panel connector between the panel and the RS controller is broken/placed
|
||||
- Improved the performance of the control panel hitbox rendering
|
||||
|
||||
####Version 1.5-11
|
||||
#####Version 1.5-11
|
||||
- Updated to Minecraft 1.11.2
|
||||
- Added Panel Meters to monitor a redstone signal with reasonable accuracy
|
||||
- Multiple components on the same panel network can modify the same signal now without causing undefined behavior
|
||||
- Lock Switches no longer break the model cache
|
||||
|
||||
###Minecraft 1.10.2
|
||||
|
||||
####Version 1.4-18
|
||||
- Fixed a crash with SpongeForge, chunk loading issues without
|
||||
- Fixed some components resetting on chunk unload
|
||||
|
||||
|
||||
####Version 1.4-16
|
||||
- Backported a lot of fixes from 1.11 and 1.12
|
||||
|
||||
####Version 1.4-10
|
||||
#####Version 1.4-10
|
||||
- added lock switches for control panels (backport from 1.11)
|
||||
- Can only be turned on by someone with the correct key to prevent unauthorized access
|
||||
- up to 10 keys can be added to a keyring to reduce inventory spam
|
||||
- IC2 items can be added to the appropriate sections of the engineers toolbox (backport from 1.11)
|
||||
- Components (lighted button, indicator light, etc.) on panels now actually light up (backport from 1.11)
|
||||
- Fixed power loss when no energy is being transmitted
|
||||
|
||||
####Version 1.4-9
|
||||
#####Version 1.4-9
|
||||
- added Control Panels
|
||||
- They can be used to control and monitor a lot of redstone signals from a few blocks
|
||||
|
||||
####Version 1.3-8
|
||||
#####Version 1.3-8
|
||||
- the converters and the motor don't have missing textures any more when using Chisel
|
||||
|
||||
####Version 1.3-7
|
||||
#####Version 1.3-7
|
||||
- added Jacob's Ladders/High voltage travelling arcs
|
||||
- they don't have a particular purpose aside from looking nice
|
||||
|
||||
####Version 1.2-6
|
||||
#####Version 1.2-6
|
||||
- reduced the discrepancies between IC2 cables and Industrial Wires
|
||||
- machines don't explode when they shouldn't except in some corner cases
|
||||
- potentially fixed missing textures on the mechanical converters
|
||||
- added Chinese translations (thanks SihenZhang)
|
||||
|
||||
####Version 1.2-5 (10,000 download celebratory release)
|
||||
#####Version 1.2-5 (10,000 download celebratory release)
|
||||
- added mechanical converters and the rotational motor
|
||||
- they convert between IE rotational energy (windmill, dynamo etc) and IC2 kinetic energy
|
||||
- Rotational motor: produces IE rotational energy from IF
|
||||
|
@ -185,18 +87,18 @@
|
|||
- Can be disabled in the config
|
||||
- wire coils show when they are out of range (to match the behavior of IE coils in the latest dev version)
|
||||
|
||||
####Version 1.1-4
|
||||
#####Version 1.1-4
|
||||
- fixed an insane amount of log-spam in an edgecase (probably a Vanilla or Forge bug)
|
||||
- added config values for wire length per connection and per coil item
|
||||
|
||||
####Version 1.1-3
|
||||
#####Version 1.1-3
|
||||
- fixed incompatibility with IE build 48
|
||||
- reduced the amount of calls to core IE classes to make such incompatibilities less likely
|
||||
- fixed localization of the creative tab
|
||||
|
||||
####Version 1.1-2
|
||||
#####Version 1.1-2
|
||||
- wire coils now use a different amount of wire depending on how long the connection is
|
||||
- wire coils are crafted by placing any amount of IC2 cables and/or the corresponding wire coils in a crafting table now
|
||||
- added Glass Fiber Wire
|
||||
- changed license to GPL3
|
||||
- changed the amount of connectors/relays the recipes yield
|
||||
- changed the amount of connectors/relays the recipes yield
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires;
|
||||
package malte0811.industrialWires;
|
||||
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityRSPanel;
|
||||
import malte0811.industrialwires.blocks.converter.TileEntityMechMB;
|
||||
import malte0811.industrialwires.blocks.hv.TileEntityJacobsLadder;
|
||||
import malte0811.industrialwires.blocks.hv.TileEntityMarx;
|
||||
import malte0811.industrialwires.containers.ContainerPanelComponent;
|
||||
import malte0811.industrialwires.containers.ContainerPanelCreator;
|
||||
import malte0811.industrialwires.containers.ContainerRSPanelConn;
|
||||
import malte0811.industrialwires.containers.ContainerRenameKey;
|
||||
import malte0811.industrialwires.mech_mb.MechEnergy;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
||||
import malte0811.industrialWires.containers.ContainerPanelComponent;
|
||||
import malte0811.industrialWires.containers.ContainerPanelCreator;
|
||||
import malte0811.industrialWires.containers.ContainerRSPanelConn;
|
||||
import malte0811.industrialWires.containers.ContainerRenameKey;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
|
||||
import java.util.Set;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class CommonProxy implements IGuiHandler {
|
||||
public void preInit() {
|
||||
|
@ -60,8 +60,8 @@ public class CommonProxy implements IGuiHandler {
|
|||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new ContainerPanelCreator(player.inventory, (TileEntityPanelCreator) te);
|
||||
}
|
||||
if (te instanceof TileEntityRSPanel) {
|
||||
return new ContainerRSPanelConn((TileEntityRSPanel) te);
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
return new ContainerRSPanelConn((TileEntityRSPanelConn) te);
|
||||
}
|
||||
} else if (ID == 1) {//ITEM GUI
|
||||
EnumHand h = z == 1 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
|
||||
|
@ -83,16 +83,4 @@ public class CommonProxy implements IGuiHandler {
|
|||
}
|
||||
|
||||
public void playMarxBang(TileEntityMarx tileEntityMarx, Vec3d vec3d, float energy) {}
|
||||
|
||||
public void updateMechMBTurningSound(TileEntityMechMB te, MechEnergy energy) {}
|
||||
|
||||
public void stopAllSoundsExcept(BlockPos pos, Set<?> excluded) {}
|
||||
|
||||
public boolean isSingleplayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isValidTextureSource(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemBlock;
|
||||
}
|
||||
}
|
|
@ -1,26 +1,25 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialWires;
|
||||
|
||||
package malte0811.industrialwires.hv;
|
||||
|
||||
import malte0811.industrialwires.blocks.hv.TileEntityMarx;
|
||||
|
||||
public interface IMarxTarget {
|
||||
public interface IIC2Connector {
|
||||
/**
|
||||
* called when the block with this TE is hit by a Marx discharge.
|
||||
* Return true to prevent the block from being destroyed.
|
||||
* @return leftover energy.
|
||||
*/
|
||||
boolean onHit(double energy, TileEntityMarx master);
|
||||
double insertEnergy(double eu, boolean simulate);
|
||||
}
|
|
@ -1,45 +1,33 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires;
|
||||
package malte0811.industrialWires;
|
||||
|
||||
import blusunrize.immersiveengineering.common.Config.IEConfig;
|
||||
import net.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.Config.Comment;
|
||||
import net.minecraftforge.common.config.Config.RequiresMcRestart;
|
||||
import net.minecraftforge.common.config.ConfigManager;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Config(modid = IndustrialWires.MODID)
|
||||
@Mod.EventBusSubscriber
|
||||
public class IWConfig {
|
||||
@Comment({"The maximum length of a single connection.", "Order: Tin, Copper, Gold, HV, Glass Fiber"})
|
||||
public static int[] maxLengthPerConn = {16, 16, 16, 32, 32};
|
||||
@Comment({"The maximum length of wire a coil item.", "Order: Tin, Copper, Gold, HV, Glass Fiber (as above)"})
|
||||
public static int[] maxLengthOnCoil = {1024, 1024, 1024, 2048, 2048};
|
||||
@Comment({"The factor between the IF transfer rate of the wires and the IF transfer rate corresponding to the EU transfer rate.",
|
||||
"The default value results in the same transfer rates as the standard IE wires"})
|
||||
public static double wireRatio = .5;
|
||||
@Comment({"The EU IO rates of the wires. Order is Tin, Copper, Gold, HV, Glass Fiber"})
|
||||
public static double[] ioRatesEU = {32, 128, 512, 2048, 8192};
|
||||
@Comment({"The EU loss rates of the wires (EU per block). Order is Tin, Copper, Gold, HV, Glass Fiber"})
|
||||
public static double[] euLossPerBlock = {.2, .2, .4, .8, .025};
|
||||
|
||||
@Comment({"Set this to false to completely disable any conversion between IF and EU (default: true)"})
|
||||
@RequiresMcRestart
|
||||
public static boolean enableConversion = true;
|
||||
|
||||
public static MechConversion mech;
|
||||
|
@ -53,44 +41,26 @@ public class IWConfig {
|
|||
public static double kinPerEu = 4;
|
||||
|
||||
@Comment({"The maximum amount of IF that can be converted to rotational energy", "by one motor in one tick (default: 100)"})
|
||||
@Config.RequiresWorldRestart
|
||||
public static int maxIfToMech = 100;
|
||||
@Comment({"The efficiency of the IF motor. The default value of 0.9 means that 10% of the energy are lost in the conversion."})
|
||||
public static double ifMotorEfficiency = .9;
|
||||
|
||||
@Comment({"The maximum amount of IE rotational energy that can be converted into IC2 kinetic energy", "by one converter in one tick"})
|
||||
@Config.RequiresWorldRestart
|
||||
public static double maxRotToKin = 200;
|
||||
public static double maxRotToKin = 50;
|
||||
@Comment({"The efficiency of the conversion from IE rotational energy to IC2 kinetic energy"})
|
||||
public static double rotToKinEfficiency = .7;
|
||||
|
||||
@Comment({"The maximum amount of IC2 kinetic energy that can be converted into IE rotational energy", "by one converter in one tick"})
|
||||
@Config.RequiresWorldRestart
|
||||
public static int maxKinToRot = 600;
|
||||
public static int maxKinToRot = 2400;
|
||||
@Comment({"The efficiency of the conversion from IC2 kinetic energy to IE rotational energy"})
|
||||
public static double kinToRotEfficiency = .8;
|
||||
|
||||
@Comment({"The conversion factor between Joules (the SI unit) and RF. Used for the Marx generator and the rotary converters",
|
||||
"With the default value the IE diesel generator produces 200kW"})
|
||||
public static double joulesPerRF = 200e3 / (20 * IEConfig.Machines.dieselGen_output);
|
||||
@Comment({"What energy types can be used with the mechanical multiblock. 0: None (Probably useless),",
|
||||
"1: EU (Currently useless), 2: FE, 3:EU and FE (allows conversion, default)"})
|
||||
public static int multiblockEnergyType = 3;
|
||||
|
||||
public static boolean allowMBFE() {
|
||||
return (multiblockEnergyType & 2) != 0;
|
||||
}
|
||||
|
||||
public static boolean allowMBEU() {
|
||||
return (multiblockEnergyType & 1) != 0 && IndustrialWires.hasIC2;
|
||||
}
|
||||
}
|
||||
|
||||
public static HVStuff hv;
|
||||
|
||||
public static class HVStuff {
|
||||
@Comment({"The amount of EU a Jacobs Ladder uses per tick, sorted by size of the ladder"})
|
||||
public static double[] jacobsUsageWatt = {40, 300, 2000};
|
||||
public static double[] jacobsUsageEU = {20, 50, 100};
|
||||
@Comment({"The damage dealt by a small Jacobs Ladder. Normal Ladders deal twice this damage, huge ones 3 times as much"})
|
||||
public static float jacobsBaseDmg = 5;
|
||||
@Comment({"The effect of standing somewhat close to a Marx generator discharge.",
|
||||
|
@ -99,11 +69,4 @@ public class IWConfig {
|
|||
@Comment({"Set to false to disable shaders. They are used for rendering the Marx generator and the Jacob's ladder."})
|
||||
public static boolean enableShaders = true;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent ev) {
|
||||
if (ev.getModID().equals(IndustrialWires.MODID)) {
|
||||
ConfigManager.sync(IndustrialWires.MODID, Config.Type.INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires;
|
||||
package malte0811.industrialWires;
|
||||
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires;
|
||||
package malte0811.industrialWires;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -37,7 +40,7 @@ public class IWPotions {
|
|||
setIconIndex(0, 0);
|
||||
this.setRegistryName(new ResourceLocation(IndustrialWires.MODID, "tinnitus"));
|
||||
ForgeRegistries.POTIONS.register(this);
|
||||
this.setPotionName("potion." + IndustrialWires.MODID + "." + getRegistryName().getPath());
|
||||
this.setPotionName("potion."+ IndustrialWires.MODID+"." + getRegistryName().getResourcePath());
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,21 +1,24 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires;
|
||||
package malte0811.industrialWires;
|
||||
|
||||
import malte0811.industrialwires.hv.MarxOreHandler;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
228
src/main/java/malte0811/industrialWires/IndustrialWires.java
Normal file
228
src/main/java/malte0811/industrialWires/IndustrialWires.java
Normal file
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialWires;
|
||||
|
||||
import blusunrize.immersiveengineering.ImmersiveEngineering;
|
||||
import blusunrize.immersiveengineering.api.MultiblockHandler;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.controlpanel.*;
|
||||
import malte0811.industrialWires.blocks.converter.BlockMechanicalConverter;
|
||||
import malte0811.industrialWires.blocks.converter.TileEntityIEMotor;
|
||||
import malte0811.industrialWires.blocks.converter.TileEntityMechICtoIE;
|
||||
import malte0811.industrialWires.blocks.converter.TileEntityMechIEtoIC;
|
||||
import malte0811.industrialWires.blocks.hv.BlockHVMultiblocks;
|
||||
import malte0811.industrialWires.blocks.hv.BlockJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
||||
import malte0811.industrialWires.blocks.wire.*;
|
||||
import malte0811.industrialWires.compat.Compat;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.crafting.Recipes;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import malte0811.industrialWires.hv.MultiblockMarx;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.items.ItemKey;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.network.MessageGUIInteract;
|
||||
import malte0811.industrialWires.network.MessageItemSync;
|
||||
import malte0811.industrialWires.network.MessagePanelInteract;
|
||||
import malte0811.industrialWires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialWires.util.CommandIW;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.12-72,);after:ic2",
|
||||
certificateFingerprint = "7e11c175d1e24007afec7498a1616bef0000027d")
|
||||
@Mod.EventBusSubscriber
|
||||
public class IndustrialWires {
|
||||
public static final String MODID = "industrialwires";
|
||||
public static final String VERSION = "${version}";
|
||||
public static final String MODNAME = "Industrial Wires";
|
||||
|
||||
public static final List<BlockIWBase> blocks = new ArrayList<>();
|
||||
public static final List<Item> items = new ArrayList<>();
|
||||
|
||||
@GameRegistry.ObjectHolder(MODID+":"+BlockIC2Connector.NAME)
|
||||
public static BlockIC2Connector ic2conn = null;
|
||||
@GameRegistry.ObjectHolder(MODID+":"+BlockMechanicalConverter.NAME)
|
||||
public static BlockMechanicalConverter mechConv = null;
|
||||
@GameRegistry.ObjectHolder(MODID+":"+BlockJacobsLadder.NAME)
|
||||
public static BlockJacobsLadder jacobsLadder = null;
|
||||
@GameRegistry.ObjectHolder(MODID+":"+BlockPanel.NAME)
|
||||
public static BlockPanel panel = null;
|
||||
@GameRegistry.ObjectHolder(MODID+":"+BlockHVMultiblocks.NAME)
|
||||
public static BlockHVMultiblocks hvMultiblocks = null;
|
||||
|
||||
@GameRegistry.ObjectHolder(MODID+":"+ItemIC2Coil.NAME)
|
||||
public static ItemIC2Coil coil = null;
|
||||
@GameRegistry.ObjectHolder(MODID+":"+ItemPanelComponent.NAME)
|
||||
public static ItemPanelComponent panelComponent = null;
|
||||
@GameRegistry.ObjectHolder(MODID+":"+ItemKey.ITEM_NAME)
|
||||
public static ItemKey key = null;
|
||||
public static final SimpleNetworkWrapper packetHandler = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
|
||||
|
||||
public static Logger logger;
|
||||
@Mod.Instance(MODID)
|
||||
public static IndustrialWires instance = new IndustrialWires();
|
||||
public static CreativeTabs creativeTab = new CreativeTabs(MODID) {
|
||||
|
||||
@Override
|
||||
public ItemStack getTabIconItem() {
|
||||
if (coil!=null) {
|
||||
return new ItemStack(coil, 1, 2);
|
||||
} else {
|
||||
return new ItemStack(panel, 1, 3);
|
||||
}
|
||||
}
|
||||
};
|
||||
@SidedProxy(clientSide = "malte0811.industrialWires.client.ClientProxy", serverSide = "malte0811.industrialWires.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
public static boolean hasIC2;
|
||||
public static boolean hasTechReborn;
|
||||
public static boolean isOldIE;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
hasIC2 = Loader.isModLoaded("ic2");
|
||||
hasTechReborn = Loader.isModLoaded("techreborn");
|
||||
{
|
||||
double ieThreshold = 12.74275;
|
||||
String ieVer = Loader.instance().getIndexedModList().get(ImmersiveEngineering.MODID).getDisplayVersion();
|
||||
int firstDash = ieVer.indexOf('-');
|
||||
String end = ieVer.substring(firstDash+1);
|
||||
String start = ieVer.substring(0, firstDash);
|
||||
end = end.replaceAll("[^0-9]", "");
|
||||
start = start.replaceAll("[^0-9]", "");
|
||||
double ieVerDouble = Double.parseDouble(start+"."+end);
|
||||
isOldIE = ieVerDouble<ieThreshold;
|
||||
}
|
||||
logger = e.getModLog();
|
||||
new IWConfig();
|
||||
if (hasIC2) {
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorTin.class, MODID + ":ic2ConnectorTin");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorCopper.class, MODID + ":ic2ConnectorCopper");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, MODID + ":ic2ConnectorGold");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorHV.class, MODID + ":ic2ConnectorHV");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGlass.class, MODID + ":ic2ConnectorGlass");
|
||||
// Dummy TE's with bad names used to update old TE's to the proper names
|
||||
GameRegistry.registerTileEntity(DummyTEs.TinDummy.class, MODID + "ic2ConnectorTin");
|
||||
GameRegistry.registerTileEntity(DummyTEs.CopperDummy.class, MODID + "ic2ConnectorCopper");
|
||||
GameRegistry.registerTileEntity(DummyTEs.GoldDummy.class, MODID + "ic2ConnectorGold");
|
||||
GameRegistry.registerTileEntity(DummyTEs.HVDummy.class, MODID + "ic2ConnectorHV");
|
||||
GameRegistry.registerTileEntity(DummyTEs.GlassDummy.class, MODID + "ic2ConnectorGlass");
|
||||
|
||||
if (IWConfig.enableConversion) {
|
||||
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID + ":ieMotor");
|
||||
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID + ":mechIcToIe");
|
||||
GameRegistry.registerTileEntity(TileEntityMechIEtoIC.class, MODID + ":mechIeToIc");
|
||||
}
|
||||
}
|
||||
GameRegistry.registerTileEntity(TileEntityJacobsLadder.class, MODID + ":jacobsLadder");
|
||||
GameRegistry.registerTileEntity(TileEntityMarx.class, MODID + ":marx_generator");
|
||||
GameRegistry.registerTileEntity(TileEntityPanel.class, MODID + ":control_panel");
|
||||
GameRegistry.registerTileEntity(TileEntityRSPanelConn.class, MODID + ":control_panel_rs");
|
||||
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, MODID + ":panel_creator");
|
||||
GameRegistry.registerTileEntity(TileEntityUnfinishedPanel.class, MODID + ":unfinished_panel");
|
||||
GameRegistry.registerTileEntity(TileEntityComponentPanel.class, MODID + ":single_component_panel");
|
||||
|
||||
proxy.preInit();
|
||||
Compat.preInit();
|
||||
MarxOreHandler.preInit();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event) {
|
||||
|
||||
if (IWConfig.enableConversion&&hasIC2) {
|
||||
event.getRegistry().register(new BlockMechanicalConverter());
|
||||
}
|
||||
if (hasIC2) {
|
||||
event.getRegistry().register(new BlockIC2Connector());
|
||||
}
|
||||
event.getRegistry().register(new BlockJacobsLadder());
|
||||
event.getRegistry().register(new BlockPanel());
|
||||
event.getRegistry().register(new BlockHVMultiblocks());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||
for (BlockIWBase b:blocks) {
|
||||
event.getRegistry().register(b.createItemBlock());
|
||||
}
|
||||
|
||||
if (hasIC2) {
|
||||
event.getRegistry().register(new ItemIC2Coil());
|
||||
}
|
||||
event.getRegistry().register(new ItemPanelComponent());
|
||||
event.getRegistry().register(new ItemKey());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
|
||||
Recipes.addRecipes(event.getRegistry());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent e) {
|
||||
MultiblockMarx.INSTANCE = new MultiblockMarx();
|
||||
MultiblockHandler.registerMultiblock(MultiblockMarx.INSTANCE);
|
||||
|
||||
packetHandler.registerMessage(MessageTileSyncIW.HandlerClient.class, MessageTileSyncIW.class, 0, Side.CLIENT);
|
||||
packetHandler.registerMessage(MessagePanelInteract.HandlerServer.class, MessagePanelInteract.class, 1, Side.SERVER);
|
||||
packetHandler.registerMessage(MessageGUIInteract.HandlerServer.class, MessageGUIInteract.class, 2, Side.SERVER);
|
||||
packetHandler.registerMessage(MessageItemSync.HandlerServer.class, MessageItemSync.class, 3, Side.SERVER);
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
||||
IWPotions.init();
|
||||
Compat.init();
|
||||
MarxOreHandler.init();
|
||||
PanelComponent.init();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
PanelUtils.PANEL_ITEM = Item.getItemFromBlock(panel);
|
||||
proxy.postInit();
|
||||
}
|
||||
@Mod.EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
event.registerServerCommand(new CommandIW());
|
||||
}
|
||||
}
|
|
@ -1,28 +1,30 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IPlayerInteraction;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.util.MiscUtils;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
@ -55,7 +57,7 @@ public abstract class BlockIWBase extends Block {
|
|||
super(mat);
|
||||
setHardness(3.0F);
|
||||
setResistance(15.0F);
|
||||
setTranslationKey(IndustrialWires.MODID + "." + name);
|
||||
setUnlocalizedName(IndustrialWires.MODID + "." + name);
|
||||
setRegistryName(IndustrialWires.MODID, name);
|
||||
setCreativeTab(IndustrialWires.creativeTab);
|
||||
IndustrialWires.blocks.add(this);
|
||||
|
@ -179,9 +181,8 @@ public abstract class BlockIWBase extends Block {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (te instanceof IPlayerInteraction) {
|
||||
if (((IPlayerInteraction) te).interact(side, player, hand, heldItem, hitX, hitY, hitZ)) {
|
||||
} else if (te instanceof IEBlockInterfaces.IPlayerInteraction) {
|
||||
if (((IEBlockInterfaces.IPlayerInteraction) te).interact(side, player, hand, heldItem, hitX, hitY, hitZ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -221,34 +222,5 @@ public abstract class BlockIWBase extends Block {
|
|||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStrongPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof IEBlockInterfaces.IRedstoneOutput) {
|
||||
return ((IEBlockInterfaces.IRedstoneOutput) te).getStrongRSOutput(state, side);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof IEBlockInterfaces.IRedstoneOutput) {
|
||||
return ((IEBlockInterfaces.IRedstoneOutput) te).getWeakRSOutput(state, side);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, @Nullable EnumFacing side) {
|
||||
if (side!=null) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof IEBlockInterfaces.IRedstoneOutput) {
|
||||
return ((IEBlockInterfaces.IRedstoneOutput) te).canConnectRedstone(state, side);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract IProperty[] getProperties();
|
||||
}
|
|
@ -1,22 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -71,7 +76,7 @@ public abstract class BlockIWMultiblock extends BlockIWBase {
|
|||
public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof TileEntityIWMultiblock) {
|
||||
return ((TileEntityIWMultiblock) te).getOriginalItem();
|
||||
return MiscUtils.getItemStack(((TileEntityIWMultiblock) te).getOriginalBlock(), world, pos);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
|
@ -1,18 +1,21 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxConnection;
|
||||
import blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxProvider;
|
|
@ -1,23 +1,25 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.compat;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
public interface IBlockAction<P, R> {
|
||||
R run(World w, BlockPos pos, P f);
|
||||
public interface IBlockBoundsIW {
|
||||
AxisAlignedBB getBoundingBox();
|
||||
}
|
|
@ -1,20 +1,24 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGeneralMultiblock;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
|
@ -1,18 +1,21 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
public interface IMetaEnum {
|
||||
Object[] getValues();
|
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
|
@ -1,25 +1,25 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface ISyncReceiver {
|
||||
@SideOnly(Side.CLIENT)
|
||||
void onSync(NBTTagCompound nbt);
|
||||
}
|
|
@ -1,39 +1,39 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.converter;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum MechanicalMBBlockType implements IStringSerializable {
|
||||
NO_MODEL,
|
||||
END,
|
||||
OTHER_END,
|
||||
COIL_4_PHASE,
|
||||
COIL_1_PHASE,
|
||||
SHAFT_BASIC,
|
||||
SHAFT_4_PHASE,
|
||||
SHAFT_1_PHASE,
|
||||
SHAFT_COMMUTATOR,
|
||||
FLYWHEEL,
|
||||
SPEEDOMETER,
|
||||
SHAFT_COMMUTATOR_4;
|
||||
public static final MechanicalMBBlockType[] VALUES = values();
|
||||
public final class IWProperties {
|
||||
private IWProperties() {}
|
||||
public static PropertyEnum<MarxType> MARX_TYPE = PropertyEnum.create("marx_type", MarxType.class);
|
||||
public enum MarxType implements IStringSerializable {
|
||||
NO_MODEL,
|
||||
BOTTOM,
|
||||
STAGE,
|
||||
TOP,
|
||||
CONNECTOR;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +1,24 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -45,12 +48,12 @@ public class ItemBlockIW extends ItemBlock {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTranslationKey(ItemStack stack) {
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
int meta = stack.getMetadata();
|
||||
if (values != null) {
|
||||
return block.getTranslationKey() + "." + values[meta].toString().toLowerCase();
|
||||
return block.getUnlocalizedName() + "." + values[meta].toString().toLowerCase();
|
||||
} else {
|
||||
return block.getTranslationKey();
|
||||
return block.getUnlocalizedName();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +1,33 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class TileEntityIWBase extends TileEntity {
|
||||
protected static final String ENERGY_TAG = "energy";
|
||||
protected static final String BUFFER_TAG = "buffer";
|
||||
protected static final String DIR_TAG = "dir";
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
|
@ -56,36 +57,11 @@ public abstract class TileEntityIWBase extends TileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
readNBT(pkt.getNbtCompound(), true);
|
||||
}
|
||||
|
||||
public void triggerRenderUpdate() {
|
||||
if (world!=null) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
world.addBlockEvent(pos, state.getBlock(), 255, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
if (world.isRemote) {
|
||||
IndustrialWires.proxy.stopAllSoundsExcept(pos, ImmutableSet.of());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
if (world.isRemote) {
|
||||
IndustrialWires.proxy.stopAllSoundsExcept(pos, ImmutableSet.of());
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void writeNBT(NBTTagCompound out, boolean updatePacket);
|
||||
|
||||
public abstract void readNBT(NBTTagCompound in, boolean updatePacket);
|
|
@ -1,25 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks;
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGeneralMultiblock;
|
||||
import malte0811.industrialwires.util.MiscUtils;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -33,15 +35,14 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements IGeneralMultiblock,
|
||||
IDirectionalTile {
|
||||
public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements IGeneralMultiblock {
|
||||
protected final static String OFFSET = "offset";
|
||||
protected final static String FORMED = "formed";
|
||||
protected final static String MIRRORED = "mirrored";
|
||||
protected final static String FACING = "facing";
|
||||
//HFR
|
||||
protected Vec3i size;
|
||||
public Vec3i offset = new Vec3i(0, 1, 0);
|
||||
public Vec3i offset = new Vec3i(0, 0, 0);
|
||||
public boolean formed;
|
||||
public boolean mirrored;
|
||||
public long onlyLocalDissassembly;
|
||||
|
@ -49,10 +50,6 @@ public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements
|
|||
@Nonnull
|
||||
protected abstract BlockPos getOrigin();
|
||||
public abstract IBlockState getOriginalBlock();
|
||||
public ItemStack getOriginalItem() {
|
||||
IBlockState state = getOriginalBlock();
|
||||
return new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
|
||||
}
|
||||
public BiConsumer<World, BlockPos> getOriginalBlockPlacer() {
|
||||
return (w, p)->w.setBlockState(p, getOriginalBlock());
|
||||
}
|
||||
|
@ -78,7 +75,6 @@ public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements
|
|||
T master = master(here);
|
||||
return master!=null?master:def;
|
||||
}
|
||||
|
||||
public void disassemble() {
|
||||
if (formed && !world.isRemote) {
|
||||
BlockPos startPos = getOrigin();
|
||||
|
@ -98,7 +94,7 @@ public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements
|
|||
if (!pos.equals(this.pos)) {
|
||||
part.getOriginalBlockPlacer().accept(world, pos);
|
||||
} else if (part.getOriginalBlock()!=null) {
|
||||
ItemStack drop = getOriginalItem();
|
||||
ItemStack drop = MiscUtils.getItemStack(part.getOriginalBlock(), world, pos);
|
||||
world.spawnEntity(new EntityItem(world, pos.getX()+.5,pos.getY()+.5,pos.getZ()+.5, drop));
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +119,7 @@ public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements
|
|||
mirrored = in.getBoolean(MIRRORED);
|
||||
int[] offset = in.getIntArray(OFFSET);
|
||||
this.offset = new Vec3i(offset[0], offset[1], offset[2]);
|
||||
facing = EnumFacing.byHorizontalIndex(in.getInteger(FACING));
|
||||
facing = EnumFacing.getHorizontal(in.getInteger(FACING));
|
||||
}
|
||||
|
||||
public Vec3i getSize() {
|
||||
|
@ -141,36 +137,4 @@ public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements
|
|||
protected int dot(Vec3i a, Vec3i b) {
|
||||
return a.getX()*b.getX()+a.getY()*b.getY()+a.getZ()*b.getZ();
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(@Nonnull EnumFacing facing) {
|
||||
this.facing = facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFacingLimitation() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirrorFacingOnPlacement(@Nonnull EntityLivingBase placer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHammerRotate(@Nonnull EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull EntityLivingBase entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRotate(@Nonnull EnumFacing axis) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,27 +1,30 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.controlpanel;
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.BlockIWBase;
|
||||
import malte0811.industrialwires.blocks.IMetaEnum;
|
||||
import malte0811.industrialwires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialwires.controlpanel.PropertyComponents;
|
||||
import malte0811.industrialwires.util.MiscUtils;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
@ -47,6 +50,7 @@ import net.minecraftforge.common.property.IUnlistedProperty;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||
public static final PropertyEnum<BlockTypes_Panel> type = PropertyEnum.create("type", BlockTypes_Panel.class);
|
||||
|
@ -81,17 +85,13 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
case TOP:
|
||||
return new TileEntityPanel();
|
||||
case RS_WIRE:
|
||||
return new TileEntityRSPanelIE();
|
||||
return new TileEntityRSPanelConn();
|
||||
case CREATOR:
|
||||
return new TileEntityPanelCreator();
|
||||
case UNFINISHED:
|
||||
return new TileEntityUnfinishedPanel();
|
||||
case SINGLE_COMP:
|
||||
return new TileEntityComponentPanel();
|
||||
case DUMMY:
|
||||
return new TileEntityGeneralCP();
|
||||
case OTHER_RS_WIRES:
|
||||
return new TileEntityRSPanelOthers();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
state.withProperty(type, BlockTypes_Panel.SINGLE_COMP);
|
||||
} else if (te instanceof TileEntityPanel) {
|
||||
state.withProperty(type, BlockTypes_Panel.TOP);
|
||||
} else if (te instanceof TileEntityRSPanelIE) {
|
||||
} else if (te instanceof TileEntityRSPanelConn) {
|
||||
state.withProperty(type, BlockTypes_Panel.RS_WIRE);
|
||||
}
|
||||
return state;
|
||||
|
@ -194,7 +194,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (!super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ) && hand == EnumHand.MAIN_HAND) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof TileEntityRSPanel) {
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
if (!world.isRemote) {
|
||||
player.openGui(IndustrialWires.instance, 0, te.getWorld(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
}
|
||||
|
@ -226,7 +226,48 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
super.harvestBlock(worldIn, player, pos, state, te, stack);
|
||||
if (te instanceof TileEntityPanel) {
|
||||
for (PanelComponent pc:((TileEntityPanel) te).getComponents()) {
|
||||
pc.dropItems();
|
||||
pc.dropItems((TileEntityPanel)te);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state) {
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
//break connections
|
||||
List<BlockPos> panels = PanelUtils.discoverPanelParts(worldIn, pos, 11 * 11 * 11);
|
||||
for (BlockPos p : panels) {
|
||||
if (!p.equals(pos)) {
|
||||
TileEntity panelPart = worldIn.getTileEntity(p);
|
||||
if (panelPart instanceof TileEntityPanel) {
|
||||
((TileEntityPanel) panelPart).removeAllRSCons();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
|
||||
super.onBlockAdded(worldIn, pos, state);
|
||||
List<BlockPos> panels = PanelUtils.discoverPanelParts(worldIn, pos, 11 * 11 * 11);
|
||||
for (BlockPos p : panels) {
|
||||
if (!p.equals(pos)) {
|
||||
TileEntity panelPart = worldIn.getTileEntity(p);
|
||||
if (panelPart instanceof TileEntityPanel) {
|
||||
((TileEntityPanel) panelPart).firstTick = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
super.neighborChanged(state, world, pos, blockIn, fromPos);
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof TileEntityComponentPanel) {
|
||||
((TileEntityComponentPanel)te).updateRS();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -254,8 +295,8 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
|
||||
@Override
|
||||
public int getWeakPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
if (state.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
||||
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
||||
TileEntity te = blockAccess.getTileEntity(pos);
|
||||
if (te instanceof TileEntityComponentPanel) {
|
||||
return ((TileEntityComponentPanel)te).getRSOutput();
|
||||
|
@ -263,17 +304,4 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
|
||||
if (!worldIn.isRemote) {
|
||||
TileEntityGeneralCP panel = MiscUtils.getLoadedTE(worldIn, pos, TileEntityGeneralCP.class);
|
||||
if (panel instanceof TileEntityComponentPanel) {
|
||||
((TileEntityComponentPanel) panel).updateRSInput();
|
||||
} else if (panel instanceof TileEntityRSPanelOthers) {
|
||||
((TileEntityRSPanelOthers)panel).updateInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +1,23 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.controlpanel;
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.compat.Compat;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
@ -26,18 +28,18 @@ public enum BlockTypes_Panel implements IStringSerializable {
|
|||
DUMMY,
|
||||
CREATOR,
|
||||
UNFINISHED,
|
||||
SINGLE_COMP,
|
||||
OTHER_RS_WIRES;
|
||||
SINGLE_COMP;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public boolean isPanelConnector() {
|
||||
return this != CREATOR && this != UNFINISHED;
|
||||
}
|
||||
|
||||
public boolean showInCreative() {
|
||||
if (this==OTHER_RS_WIRES) {
|
||||
return Compat.enableOtherRS;
|
||||
}
|
||||
return this != SINGLE_COMP;
|
||||
}
|
||||
}
|
|
@ -1,32 +1,34 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.controlpanel;
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.api.tool.IConfigurableTool;
|
||||
import malte0811.industrialwires.blocks.ItemBlockIW;
|
||||
import malte0811.industrialWires.blocks.ItemBlockIW;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.ANGLE;
|
||||
import static malte0811.industrialwires.util.NBTKeys.HEIGHT;
|
||||
|
||||
public class ItemBlockPanel extends ItemBlockIW implements IConfigurableTool {
|
||||
private static final String HEIGHT = "height";
|
||||
private static final String ANGLE = "angle";
|
||||
|
||||
public ItemBlockPanel(Block b) {
|
||||
super(b);
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import net.minecraft.block.BlockRedstoneWire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialWires.util.MiscUtils.apply;
|
||||
|
||||
public class TileEntityComponentPanel extends TileEntityPanel {
|
||||
private int rsOut = 0;
|
||||
private Consumer<byte[]> rsIn;
|
||||
public TileEntityComponentPanel() {
|
||||
components = new PropertyComponents.AABBPanelProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
for (PanelComponent pc : components) {
|
||||
pc.update(this);
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
if (firstTick&&components.size()>0) {
|
||||
PanelComponent pc = components.get(0);
|
||||
pc.registerRSOutput(-1, (channel, value, pcTmp)->{
|
||||
rsOut = value;
|
||||
if (!isInvalid()) {
|
||||
markBlockForUpdate(pos);
|
||||
markBlockForUpdate(pos.offset(components.getTop(), -1));
|
||||
}
|
||||
});
|
||||
rsIn = pc.getRSInputHandler(-1, this);
|
||||
updateRS();
|
||||
firstTick = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRS() {
|
||||
if (rsIn != null) {
|
||||
int value = world.isBlockIndirectlyGettingPowered(pos);
|
||||
if (value == 0) {
|
||||
for (EnumFacing f : EnumFacing.HORIZONTALS) {
|
||||
IBlockState state = world.getBlockState(pos.offset(f));
|
||||
if (state.getBlock() == Blocks.REDSTONE_WIRE && state.getValue(BlockRedstoneWire.POWER) > value)
|
||||
value = state.getValue(BlockRedstoneWire.POWER);
|
||||
}
|
||||
}
|
||||
byte[] tmp = new byte[16];
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
tmp[i] = (byte) value;
|
||||
}
|
||||
rsIn.accept(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
public void markBlockForUpdate(BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(getPos());
|
||||
world.notifyBlockUpdate(pos,state,state,3);
|
||||
world.notifyNeighborsOfStateChange(pos, state.getBlock(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
if (defAABB == null) {
|
||||
AxisAlignedBB base = ((PropertyComponents.AABBPanelProperties)components).getPanelBoundingBox();
|
||||
defAABB = apply(components.getPanelBaseTransform(), base.setMaxY(components.getMaxHeight()));
|
||||
}
|
||||
return defAABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRS(TileEntityRSPanelConn te) {
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterRS(TileEntityRSPanelConn te) {
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interactsWithRSWires() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRSOutput() {
|
||||
return rsOut;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getTileDrop(@Nonnull EntityPlayer player, @Nonnull IBlockState state) {
|
||||
if (components.size()<1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ItemPanelComponent.stackFromComponent(components.get(0));
|
||||
}
|
||||
}
|
|
@ -1,29 +1,32 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.controlpanel;
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IPlayerInteraction;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialwires.controlpanel.*;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialwires.network.MessagePanelInteract;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialWires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialWires.controlpanel.*;
|
||||
import malte0811.industrialWires.network.MessagePanelInteract;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -31,6 +34,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
|
@ -38,18 +42,22 @@ import net.minecraft.util.math.AxisAlignedBB;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static malte0811.industrialwires.util.MiscUtils.apply;
|
||||
import static malte0811.industrialWires.util.MiscUtils.apply;
|
||||
|
||||
public class TileEntityPanel extends TileEntityGeneralCP implements IDirectionalTile, IBlockBoundsIW, IPlayerInteraction,
|
||||
ITickable, IEBlockInterfaces.ITileDrop {
|
||||
public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTile, IBlockBoundsIW, IPlayerInteraction, ITickable, IEBlockInterfaces.ITileDrop {
|
||||
protected PropertyComponents.PanelRenderProperties components = new PropertyComponents.PanelRenderProperties();
|
||||
public boolean firstTick = true;
|
||||
// non-rendered properties
|
||||
private Set<TileEntityRSPanelConn> rsPorts = new HashSet<>();
|
||||
|
||||
{
|
||||
int[] colors = {
|
||||
|
@ -57,10 +65,9 @@ public class TileEntityPanel extends TileEntityGeneralCP implements IDirectional
|
|||
4673362, 10329495, 1481884, 8991416, 3949738, 8606770, 6192150
|
||||
};
|
||||
for (int i = 2; i < 14; i++) {
|
||||
int color = colors[i-2];
|
||||
IndicatorLight ind = new IndicatorLight(new RSChannel(0, (byte) (i - 2)), color);
|
||||
LightedButton btn = new LightedButton(color, false, true,
|
||||
new RSChannel(0, (byte)(i-2)));
|
||||
int color = colors[i];
|
||||
IndicatorLight ind = new IndicatorLight(0, (byte) (i - 2), color);
|
||||
LightedButton btn = new LightedButton(color, false, true, 1, i - 2);
|
||||
Label lbl = new Label("->", color);
|
||||
ind.setX(0);
|
||||
ind.setY(i / 16F);
|
||||
|
@ -75,25 +82,24 @@ public class TileEntityPanel extends TileEntityGeneralCP implements IDirectional
|
|||
components.add(lbl);
|
||||
components.add(btn);
|
||||
}
|
||||
for (PanelComponent pc:components) {
|
||||
pc.setPanel(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!world.isRemote) {
|
||||
for (PanelComponent pc : components) {
|
||||
pc.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetworkAndInit(ControlPanelNetwork newNet) {
|
||||
super.setNetworkAndInit(newNet);
|
||||
for (PanelComponent pc : components) {
|
||||
pc.setNetwork(newNet);
|
||||
pc.update(this);
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
if (firstTick) {
|
||||
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos, 100);
|
||||
for (BlockPos bp : parts) {
|
||||
TileEntity te = world.getTileEntity(bp);
|
||||
if (te instanceof TileEntityRSPanelConn && !rsPorts.contains(te)) {
|
||||
((TileEntityRSPanelConn) te).registerPanel(this);
|
||||
}
|
||||
}
|
||||
firstTick = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,13 +113,13 @@ public class TileEntityPanel extends TileEntityGeneralCP implements IDirectional
|
|||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
readFromItemNBT(in);
|
||||
components.setFacing(EnumFacing.byHorizontalIndex(in.getInteger("facing")));
|
||||
components.setTop(EnumFacing.byIndex(in.getInteger("top")));
|
||||
components.setFacing(EnumFacing.getHorizontal(in.getInteger("facing")));
|
||||
components.setTop(EnumFacing.getFront(in.getInteger("top")));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getTileDrop(@Nullable EntityPlayer player, @Nonnull IBlockState state) {
|
||||
public ItemStack getTileDrop(@Nonnull EntityPlayer player, @Nonnull IBlockState state) {
|
||||
NBTTagCompound ret = new NBTTagCompound();
|
||||
writeToItemNBT(ret, true);
|
||||
ItemStack retStack = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
|
||||
|
@ -132,17 +138,7 @@ public class TileEntityPanel extends TileEntityGeneralCP implements IDirectional
|
|||
if (nbt != null) {
|
||||
NBTTagList l = nbt.getTagList("components", 10);
|
||||
PanelUtils.readListFromNBT(l, components);
|
||||
panelNetwork.removeIOFor(this);
|
||||
for (PanelComponent pc : components) {
|
||||
pc.setPanel(this);
|
||||
if (world == null || !world.isRemote) {
|
||||
pc.setNetwork(panelNetwork);
|
||||
}
|
||||
}
|
||||
components.setHeight(nbt.getFloat("height"));
|
||||
if (nbt.hasKey("texture", Constants.NBT.TAG_COMPOUND)) {
|
||||
components.setTextureSource(new ItemStack(nbt.getCompoundTag("texture")));
|
||||
}
|
||||
components.setAngle(nbt.getFloat("angle"));
|
||||
}
|
||||
defAABB = null;
|
||||
|
@ -158,7 +154,6 @@ public class TileEntityPanel extends TileEntityGeneralCP implements IDirectional
|
|||
nbt.setTag("components", comps);
|
||||
nbt.setFloat("height", components.getHeight());
|
||||
nbt.setFloat("angle", components.getAngle());
|
||||
nbt.setTag("texture", components.getTextureSource().serializeNBT());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -231,9 +226,9 @@ public class TileEntityPanel extends TileEntityGeneralCP implements IDirectional
|
|||
Matrix4 mat = components.getPanelTopTransformInverse();
|
||||
PanelComponent retPc = null;
|
||||
RayTraceResult retRay = null;
|
||||
Vec3d playerPosRelative = player.getPositionVector().add(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
|
||||
Vec3d playerPosRelative = player.getPositionVector().addVector(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
|
||||
Vec3d playerPosTransformed = mat.apply(playerPosRelative);
|
||||
Vec3d hitRel = hitAbs ? hitVec.add(-pos.getX(), -pos.getY(), -pos.getZ()) : hitVec;
|
||||
Vec3d hitRel = hitAbs ? hitVec.addVector(-pos.getX(), -pos.getY(), -pos.getZ()) : hitVec;
|
||||
RayTraceResult r = getBoundingBox().calculateIntercept(playerPosRelative, playerPosRelative.add(player.getLookVec().scale(200)));
|
||||
if (r != null && r.hitVec != null) {
|
||||
hitRel = r.hitVec;
|
||||
|
@ -286,7 +281,53 @@ public class TileEntityPanel extends TileEntityGeneralCP implements IDirectional
|
|||
|
||||
public void interactServer(Vec3d hitRelative, int pcId, EntityPlayerMP player) {
|
||||
if (pcId >= 0 && pcId < components.size()) {
|
||||
components.get(pcId).interactWith(hitRelative, player);
|
||||
components.get(pcId).interactWith(hitRelative, this, player);
|
||||
}
|
||||
}
|
||||
|
||||
public void triggerRenderUpdate() {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
world.addBlockEvent(pos, state.getBlock(), 255, 0);
|
||||
}
|
||||
|
||||
public void registerRS(TileEntityRSPanelConn te) {
|
||||
rsPorts.add(te);
|
||||
}
|
||||
|
||||
public void unregisterRS(TileEntityRSPanelConn te) {
|
||||
if (!tileEntityInvalid) {
|
||||
rsPorts.remove(te);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
for (PanelComponent pc : components) {
|
||||
pc.invalidate(this);
|
||||
}
|
||||
removeAllRSCons();
|
||||
}
|
||||
|
||||
public void removeAllRSCons() {
|
||||
for (TileEntityRSPanelConn rs : rsPorts) {
|
||||
rs.unregisterPanel(this, true, false);
|
||||
}
|
||||
rsPorts.clear();
|
||||
firstTick = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
for (PanelComponent pc : components) {
|
||||
pc.invalidate(this);
|
||||
}
|
||||
removeAllRSCons();
|
||||
}
|
||||
|
||||
public boolean interactsWithRSWires() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,28 +1,31 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.controlpanel;
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialwires.blocks.INetGUI;
|
||||
import malte0811.industrialwires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialwires.controlpanel.MessageType;
|
||||
import malte0811.industrialwires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialwires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialwires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialWires.blocks.INetGUI;
|
||||
import malte0811.industrialWires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialWires.controlpanel.MessageType;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -115,12 +118,7 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
|
|||
}
|
||||
}
|
||||
if (valid) {
|
||||
NBTTagCompound panelNBT;
|
||||
if (inv.hasTagCompound()) {
|
||||
panelNBT = inv.getTagCompound().copy();
|
||||
} else {
|
||||
panelNBT = new NBTTagCompound();
|
||||
}
|
||||
NBTTagCompound panelNBT = new NBTTagCompound();
|
||||
writeToItemNBT(panelNBT, true);
|
||||
ItemStack panel = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
|
||||
panel.setTagCompound(panelNBT);
|
|
@ -0,0 +1,394 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.api.TargetingInfo;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.redstone.IRedstoneConnector;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.redstone.RedstoneWireNetwork;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialWires.blocks.INetGUI;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||
import malte0811.industrialWires.util.TriConsumer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implements IRedstoneConnector, ITickable, INetGUI, IEBlockInterfaces.IDirectionalTile, IBlockBoundsIW {
|
||||
private byte[] out = new byte[16];
|
||||
private boolean dirty = true;
|
||||
private byte[] oldInput = new byte[16];
|
||||
private Set<Consumer<byte[]>> changeListeners = new HashSet<>();
|
||||
private Set<TileEntityPanel> connectedPanels = new HashSet<>();
|
||||
private EnumFacing facing = EnumFacing.NORTH;
|
||||
@Nonnull
|
||||
private RedstoneWireNetwork network = new RedstoneWireNetwork().add(this);
|
||||
private boolean hasConn = false;
|
||||
private int id;
|
||||
|
||||
{
|
||||
for (int i = 0; i < 16; i++) {
|
||||
oldInput[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (hasWorld() && !world.isRemote) {
|
||||
if (!loaded) {
|
||||
loaded = true;
|
||||
// completely reload the network
|
||||
network.removeFromNetwork(null);
|
||||
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos, 100);
|
||||
for (BlockPos bp : parts) {
|
||||
TileEntity te = world.getTileEntity(bp);
|
||||
if (te instanceof TileEntityPanel) {
|
||||
registerPanel(((TileEntityPanel) te));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dirty) {
|
||||
network.updateValues();
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
super.writeCustomNBT(out, updatePacket);
|
||||
out.setByteArray("out", this.out);
|
||||
out.setBoolean("hasConn", hasConn);
|
||||
out.setInteger("rsId", id);
|
||||
out.setInteger("facing", facing.getIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
super.readCustomNBT(in, updatePacket);
|
||||
out = in.getByteArray("out");
|
||||
hasConn = in.getBoolean("hasConn");
|
||||
id = in.getInteger("rsId");
|
||||
facing = EnumFacing.VALUES[in.getInteger("facing")];
|
||||
aabb = null;
|
||||
}
|
||||
|
||||
private final Map<PCWrapper, byte[]> outputs = new HashMap<>();
|
||||
private TriConsumer<Integer, Byte, PanelComponent> rsOut = (channel, value, pc) -> {
|
||||
PCWrapper wrapper = new PCWrapper(pc);
|
||||
if (!outputs.containsKey(wrapper)) {
|
||||
outputs.put(wrapper, new byte[16]);
|
||||
}
|
||||
if (outputs.get(wrapper)[channel] != value) {
|
||||
outputs.get(wrapper)[channel] = value;
|
||||
byte max = 0;
|
||||
Iterator<Map.Entry<PCWrapper, byte[]>> it = outputs.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<PCWrapper, byte[]> curr = it.next();
|
||||
if (curr.getKey().pc.get() == null) {
|
||||
it.remove();
|
||||
continue;
|
||||
}
|
||||
if (curr.getValue()[channel] > max) {
|
||||
max = curr.getValue()[channel];
|
||||
}
|
||||
}
|
||||
dirty = true;
|
||||
out[channel] = max;
|
||||
}
|
||||
};
|
||||
|
||||
private class PCWrapper {
|
||||
@Nonnull
|
||||
private final WeakReference<PanelComponent> pc;
|
||||
|
||||
public PCWrapper(@Nonnull PanelComponent pc) {
|
||||
this.pc = new WeakReference<>(pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PCWrapper pcWrapper = (PCWrapper) o;
|
||||
|
||||
return pcWrapper.pc.get() == pc.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return System.identityHashCode(pc.get());
|
||||
}
|
||||
}
|
||||
|
||||
public void registerPanel(TileEntityPanel panel) {
|
||||
if (panel.interactsWithRSWires()) {
|
||||
PropertyComponents.PanelRenderProperties p = panel.getComponents();
|
||||
for (PanelComponent pc : p) {
|
||||
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
|
||||
if (listener != null) {
|
||||
changeListeners.add(listener);
|
||||
listener.accept(network.channelValues);
|
||||
}
|
||||
pc.registerRSOutput(id, rsOut);
|
||||
}
|
||||
panel.registerRS(this);
|
||||
connectedPanels.add(panel);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterPanel(TileEntityPanel panel, boolean remove, boolean callPanel) {
|
||||
out = new byte[16];
|
||||
PropertyComponents.PanelRenderProperties p = panel.getComponents();
|
||||
for (PanelComponent pc : p) {
|
||||
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
|
||||
if (listener != null) {
|
||||
listener.accept(new byte[16]);
|
||||
changeListeners.remove(listener);
|
||||
}
|
||||
pc.unregisterRSOutput(id, rsOut);
|
||||
outputs.remove(new PCWrapper(pc));
|
||||
}
|
||||
if (callPanel) {
|
||||
panel.unregisterRS(this);
|
||||
}
|
||||
if (remove) {
|
||||
connectedPanels.remove(panel);
|
||||
}
|
||||
for (TileEntityPanel te : connectedPanels) {
|
||||
for (PanelComponent pc : te.getComponents()) {
|
||||
pc.registerRSOutput(id, rsOut);
|
||||
}
|
||||
}
|
||||
network.updateValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(@Nonnull RedstoneWireNetwork net) {
|
||||
network = net;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public RedstoneWireNetwork getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange() {
|
||||
if (!Arrays.equals(oldInput, network.channelValues)) {
|
||||
oldInput = Arrays.copyOf(network.channelValues, 16);
|
||||
for (Consumer<byte[]> c : changeListeners) {
|
||||
c.accept(oldInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInput(byte[] currIn) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
currIn[i] = (byte) Math.max(currIn[i], out[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getConnectionMaster(@Nullable WireType wire, TargetingInfo target) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType wire, TargetingInfo targetingInfo) {
|
||||
return wire == WireType.REDSTONE && !hasConn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectCable(WireType wireType, TargetingInfo targetingInfo, IImmersiveConnectable other) {
|
||||
hasConn = true;
|
||||
if (other instanceof IRedstoneConnector && ((IRedstoneConnector) other).getNetwork() != network) {
|
||||
network.mergeNetwork(((IRedstoneConnector) other).getNetwork());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WireType getCableLimiter(TargetingInfo targetingInfo) {
|
||||
return WireType.REDSTONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowEnergyToPass(ImmersiveNetHandler.Connection connection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCable(ImmersiveNetHandler.Connection connection) {
|
||||
hasConn = false;
|
||||
network.removeFromNetwork(this);
|
||||
this.markDirty();
|
||||
if (world != null) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable other) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .0625, .5 + side.getFrontOffsetY() * .0625, .5 + side.getFrontOffsetZ() * .0625);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection connection) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
double conRadius = connection.cableType.getRenderDiameter() / 2;
|
||||
return new Vec3d(.5 - conRadius * side.getFrontOffsetX(), .5 - conRadius * side.getFrontOffsetY(), .5 - conRadius * side.getFrontOffsetZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
for (TileEntityPanel panel : connectedPanels) {
|
||||
unregisterPanel(panel, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
for (TileEntityPanel panel : connectedPanels) {
|
||||
unregisterPanel(panel, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(NBTTagCompound nbt, EntityPlayer p) {
|
||||
if (nbt.hasKey("rsId")) {
|
||||
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos, 100);
|
||||
List<TileEntityPanel> tes = new ArrayList<>(parts.size());
|
||||
for (BlockPos bp : parts) {
|
||||
TileEntity te = world.getTileEntity(bp);
|
||||
if (te instanceof TileEntityPanel) {
|
||||
tes.add((TileEntityPanel) te);
|
||||
unregisterPanel((TileEntityPanel) te, true, true);
|
||||
}
|
||||
}
|
||||
id = nbt.getInteger("rsId");
|
||||
out = new byte[16];
|
||||
for (TileEntityPanel panel : tes) {
|
||||
registerPanel(panel);
|
||||
}
|
||||
network.updateValues();
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
world.addBlockEvent(pos, state.getBlock(), 255, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getConnectorWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public int getRsId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(@Nonnull EnumFacing facing) {
|
||||
this.facing = facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFacingLimitation() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirrorFacingOnPlacement(@Nonnull EntityLivingBase placer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHammerRotate(@Nonnull EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull EntityLivingBase entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRotate(@Nonnull EnumFacing axis) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private AxisAlignedBB aabb;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
if (aabb == null) {
|
||||
double h = 9 / 16D;
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
aabb = new AxisAlignedBB(0, 0, 0, 1, h, 1);
|
||||
break;
|
||||
case UP:
|
||||
aabb = new AxisAlignedBB(0, 1 - h, 0, 1, 1, 1);
|
||||
break;
|
||||
case NORTH:
|
||||
aabb = new AxisAlignedBB(0, 0, 0, 1, 1, h);
|
||||
break;
|
||||
case SOUTH:
|
||||
aabb = new AxisAlignedBB(0, 0, 1 - h, 1, 1, 1);
|
||||
break;
|
||||
case WEST:
|
||||
aabb = new AxisAlignedBB(0, 0, 0, h, 1, 1);
|
||||
break;
|
||||
case EAST:
|
||||
aabb = new AxisAlignedBB(1 - h, 0, 0, 1, 1, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
}
|
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.controlpanel;
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
|
@ -1,22 +1,26 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks.converter;
|
||||
package malte0811.industrialWires.blocks.converter;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import malte0811.industrialwires.blocks.BlockIWBase;
|
||||
import malte0811.industrialwires.blocks.IMetaEnum;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
@ -24,6 +28,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
|
@ -1,18 +1,21 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks.converter;
|
||||
package malte0811.industrialWires.blocks.converter;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
|
@ -1,27 +1,30 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks.converter;
|
||||
package malte0811.industrialWires.blocks.converter;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.IRotationAcceptor;
|
||||
import blusunrize.immersiveengineering.api.energy.immersiveflux.FluxStorage;
|
||||
import blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxReceiver;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import malte0811.industrialwires.IWConfig.MechConversion;
|
||||
import malte0811.industrialwires.blocks.EnergyAdapter;
|
||||
import malte0811.industrialwires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialwires.util.ConversionUtil;
|
||||
import malte0811.industrialWires.IWConfig.MechConversion;
|
||||
import malte0811.industrialWires.blocks.EnergyAdapter;
|
||||
import malte0811.industrialWires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -30,15 +33,12 @@ import net.minecraft.util.ITickable;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
|
||||
public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IFluxReceiver, IDirectionalTile {
|
||||
public final double bufferMax = 2 * MechConversion.maxIfToMech * ConversionUtil.rotPerIf();
|
||||
|
||||
private double rotBuffer = 0;
|
||||
private FluxStorage energy = new FluxStorage(20 * MechConversion.maxIfToMech, 2 * MechConversion.maxIfToMech);
|
||||
private EnumFacing dir = EnumFacing.DOWN;
|
||||
|
@ -52,8 +52,7 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
}
|
||||
int max = MechConversion.maxIfToMech;
|
||||
boolean dirty = false;
|
||||
if (rotBuffer < 2 * MechConversion.maxIfToMech * ConversionUtil.rotPerIf()
|
||||
&& energy.extractEnergy(max, true) > 0) {
|
||||
if (rotBuffer < bufferMax && energy.extractEnergy(max, true) > 0) {
|
||||
int extracted = energy.extractEnergy(max, false);
|
||||
rotBuffer += extracted * ConversionUtil.rotPerIf() * MechConversion.ifMotorEfficiency;
|
||||
dirty = true;
|
||||
|
@ -72,19 +71,19 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
dir = EnumFacing.VALUES[in.getByte(DIRECTION)];
|
||||
energy.readFromNBT(in.getCompoundTag(ENERGY));
|
||||
dir = EnumFacing.VALUES[in.getByte(DIR_TAG)];
|
||||
energy.readFromNBT(in.getCompoundTag(ENERGY_TAG));
|
||||
receiver = null;
|
||||
rotBuffer = in.getDouble(BUFFER);
|
||||
rotBuffer = in.getDouble(BUFFER_TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(DIRECTION, (byte) dir.getIndex());
|
||||
out.setByte(DIR_TAG, (byte) dir.getIndex());
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
energy.writeToNBT(nbt);
|
||||
out.setTag(ENERGY, nbt);
|
||||
out.setDouble(BUFFER, rotBuffer);
|
||||
out.setTag(ENERGY_TAG, nbt);
|
||||
out.setDouble(BUFFER_TAG, rotBuffer);
|
||||
}
|
||||
|
||||
// Flux energy
|
||||
|
@ -151,14 +150,11 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
private Map<EnumFacing, IEnergyStorage> energies = new HashMap<>();
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, EnumFacing facing) {
|
||||
if (capability == CapabilityEnergy.ENERGY && canConnectEnergy(facing)) {
|
||||
if (!energies.containsKey(facing))
|
||||
energies.put(facing, new EnergyAdapter(this, facing));
|
||||
return CapabilityEnergy.ENERGY.cast(energies.get(facing));
|
||||
return (T) new EnergyAdapter(this, facing);
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
|
@ -1,25 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks.converter;
|
||||
package malte0811.industrialWires.blocks.converter;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.IRotationAcceptor;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import ic2.api.energy.tile.IKineticSource;
|
||||
import malte0811.industrialwires.IWConfig.MechConversion;
|
||||
import malte0811.industrialwires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialwires.util.ConversionUtil;
|
||||
import malte0811.industrialWires.IWConfig.MechConversion;
|
||||
import malte0811.industrialWires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -29,14 +32,13 @@ import net.minecraft.util.math.BlockPos;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.BUFFER;
|
||||
import static malte0811.industrialwires.util.NBTKeys.DIRECTION;
|
||||
|
||||
public class TileEntityMechICtoIE extends TileEntityIWBase implements IDirectionalTile, ITickable {
|
||||
private EnumFacing dir = EnumFacing.DOWN;
|
||||
private int kinBuffer = 0;
|
||||
private BlockPos to;
|
||||
private BlockPos from;
|
||||
EnumFacing dir = EnumFacing.DOWN;
|
||||
int kinBuffer = 0;
|
||||
private final int kinBufMax = 2 * MechConversion.maxKinToRot;
|
||||
private final double maxInsert = ConversionUtil.rotPerKin() * MechConversion.maxKinToRot;
|
||||
BlockPos to;
|
||||
BlockPos from;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
@ -50,15 +52,14 @@ public class TileEntityMechICtoIE extends TileEntityIWBase implements IDirection
|
|||
TileEntity teFrom = world.getTileEntity(from);
|
||||
if (teFrom instanceof IKineticSource) {
|
||||
int sourceMax = ((IKineticSource) teFrom).maxrequestkineticenergyTick(dir);
|
||||
int draw = Math.min(2 * MechConversion.maxKinToRot - kinBuffer, sourceMax);
|
||||
int draw = Math.min(kinBufMax - kinBuffer, sourceMax);
|
||||
if (draw > 0) {
|
||||
kinBuffer += ((IKineticSource) teFrom).requestkineticenergy(dir, draw) * MechConversion.kinToRotEfficiency;
|
||||
}
|
||||
}
|
||||
TileEntity teTo = world.getTileEntity(to);
|
||||
if (kinBuffer > 0 && teTo instanceof IRotationAcceptor) {
|
||||
double out = Math.min(ConversionUtil.rotPerKin() * MechConversion.maxKinToRot,
|
||||
ConversionUtil.rotPerKin() * kinBuffer);
|
||||
double out = Math.min(maxInsert, ConversionUtil.rotPerKin() * kinBuffer);
|
||||
((IRotationAcceptor) teTo).inputRotation(out, dir);
|
||||
kinBuffer -= out * ConversionUtil.kinPerRot();
|
||||
}
|
||||
|
@ -67,14 +68,14 @@ public class TileEntityMechICtoIE extends TileEntityIWBase implements IDirection
|
|||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(DIRECTION, (byte) dir.getIndex());
|
||||
out.setInteger(BUFFER, kinBuffer);
|
||||
out.setByte(DIR_TAG, (byte) dir.getIndex());
|
||||
out.setInteger(BUFFER_TAG, kinBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
dir = EnumFacing.VALUES[in.getByte(DIRECTION)];
|
||||
kinBuffer = in.getInteger(BUFFER);
|
||||
dir = EnumFacing.VALUES[in.getByte(DIR_TAG)];
|
||||
kinBuffer = in.getInteger(BUFFER_TAG);
|
||||
to = null;
|
||||
from = null;
|
||||
}
|
|
@ -1,49 +1,50 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks.converter;
|
||||
package malte0811.industrialWires.blocks.converter;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.IRotationAcceptor;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import ic2.api.energy.tile.IKineticSource;
|
||||
import malte0811.industrialwires.IWConfig.MechConversion;
|
||||
import malte0811.industrialwires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialwires.util.ConversionUtil;
|
||||
import malte0811.industrialWires.IWConfig.MechConversion;
|
||||
import malte0811.industrialWires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static malte0811.industrialwires.IWConfig.MechConversion.maxRotToKin;
|
||||
import static malte0811.industrialwires.util.NBTKeys.BUFFER;
|
||||
import static malte0811.industrialwires.util.NBTKeys.DIRECTION;
|
||||
|
||||
public class TileEntityMechIEtoIC extends TileEntityIWBase implements IDirectionalTile, IRotationAcceptor, IKineticSource {
|
||||
private EnumFacing dir = EnumFacing.DOWN;
|
||||
private double rotBuffer = 0;
|
||||
EnumFacing dir = EnumFacing.DOWN;
|
||||
double rotBuffer = 0;
|
||||
private final double rotBufMax = 2 * MechConversion.maxRotToKin;
|
||||
private final int maxOutput = (int) (ConversionUtil.kinPerRot() * MechConversion.maxRotToKin);
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(DIRECTION, (byte) dir.getIndex());
|
||||
out.setDouble(BUFFER, rotBuffer);
|
||||
out.setByte(DIR_TAG, (byte) dir.getIndex());
|
||||
out.setDouble(BUFFER_TAG, rotBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
dir = EnumFacing.VALUES[in.getByte(DIRECTION)];
|
||||
rotBuffer = in.getDouble(BUFFER);
|
||||
dir = EnumFacing.VALUES[in.getByte(DIR_TAG)];
|
||||
rotBuffer = in.getDouble(BUFFER_TAG);
|
||||
}
|
||||
|
||||
// Directional
|
||||
|
@ -74,36 +75,23 @@ public class TileEntityMechIEtoIC extends TileEntityIWBase implements IDirection
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int maxrequestkineticenergyTick(EnumFacing enumFacing) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//IC2 kinetic
|
||||
@Override
|
||||
public int getConnectionBandwidth(EnumFacing f) {
|
||||
public int maxrequestkineticenergyTick(EnumFacing f) {
|
||||
if (f == dir) {
|
||||
return (int) (ConversionUtil.kinPerRot() * rotBuffer);
|
||||
return maxOutput;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int requestkineticenergy(EnumFacing enumFacing, int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawKineticEnergy(EnumFacing f, int requested, boolean simulate) {
|
||||
public int requestkineticenergy(EnumFacing f, int requested) {
|
||||
if (f == dir) {
|
||||
int stored = (int) (ConversionUtil.kinPerRot() * rotBuffer);
|
||||
int out = Math.min(requested, stored);
|
||||
if (!simulate) {
|
||||
rotBuffer -= out * ConversionUtil.rotPerKin();
|
||||
}
|
||||
int out = Math.min(maxOutput, stored);
|
||||
out = Math.min(requested, out);
|
||||
rotBuffer -= out * ConversionUtil.rotPerKin();
|
||||
return (int) (out * MechConversion.rotToKinEfficiency);
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -114,7 +102,7 @@ public class TileEntityMechIEtoIC extends TileEntityIWBase implements IDirection
|
|||
@Override
|
||||
public void inputRotation(double rotation, @Nonnull EnumFacing side) {
|
||||
if (side == dir) {
|
||||
rotBuffer = Math.min(Math.max(rotBuffer, rotation), maxRotToKin);
|
||||
rotBuffer = Math.min(rotBufMax, rotBuffer + rotation);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.hv;
|
||||
package malte0811.industrialWires.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import malte0811.industrialwires.blocks.BlockIWMultiblock;
|
||||
import malte0811.industrialwires.blocks.IMetaEnum;
|
||||
import malte0811.industrialwires.blocks.IWProperties;
|
||||
import malte0811.industrialWires.blocks.BlockIWMultiblock;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import malte0811.industrialWires.blocks.IWProperties;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
@ -90,6 +93,7 @@ public class BlockHVMultiblocks extends BlockIWMultiblock implements IMetaEnum {
|
|||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (te instanceof TileEntityMarx) {
|
||||
ret = ret.withProperty(IWProperties.MARX_TYPE, ((TileEntityMarx) te).type);
|
||||
ret = ret.withProperty(IEProperties.FACING_HORIZONTAL, ((TileEntityMarx)te).facing);
|
||||
ret = ret.withProperty(IEProperties.BOOLEANS[0], ((TileEntityMarx)te).mirrored);
|
||||
}
|
||||
return ret;
|
|
@ -1,25 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.hv;
|
||||
package malte0811.industrialWires.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import malte0811.industrialwires.blocks.BlockIWBase;
|
||||
import malte0811.industrialwires.blocks.IMetaEnum;
|
||||
import malte0811.industrialwires.blocks.IPlacementCheck;
|
||||
import malte0811.industrialwires.blocks.hv.TileEntityJacobsLadder.LadderSize;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import malte0811.industrialWires.blocks.IPlacementCheck;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder.LadderSize;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
@ -143,16 +146,24 @@ public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacem
|
|||
return new ItemStack(this, 1, getMetaFromState(state));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
||||
super.onEntityCollision(worldIn, pos, state, entityIn);
|
||||
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
||||
super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (te instanceof TileEntityJacobsLadder) {
|
||||
((TileEntityJacobsLadder) te).onEntityTouch(entityIn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (te instanceof TileEntityJacobsLadder) {
|
||||
return ((TileEntityJacobsLadder) te).onActivated(playerIn, hand);
|
||||
}
|
||||
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World w, BlockPos pos, ItemStack stack) {
|
||||
int dummyCount = LadderSize.values()[stack.getMetadata()].dummyCount;
|
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.hv;
|
||||
package malte0811.industrialWires.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockIEBase;
|
||||
|
||||
|
@ -30,7 +33,6 @@ public enum BlockTypes_HVMultiblocks implements BlockIEBase.IBlockEnum {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
|
@ -1,39 +1,41 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.hv;
|
||||
package malte0811.industrialWires.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.blocks.TileEntityIEBase;
|
||||
import com.elytradev.mirage.lighting.IColoredLight;
|
||||
import com.elytradev.mirage.lighting.Light;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import malte0811.industrialwires.IWConfig;
|
||||
import malte0811.industrialwires.IWDamageSources;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialwires.blocks.IHasDummyBlocksIW;
|
||||
import malte0811.industrialwires.blocks.ISyncReceiver;
|
||||
import malte0811.industrialwires.compat.Compat;
|
||||
import malte0811.industrialwires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialwires.util.Beziers;
|
||||
import malte0811.industrialwires.util.ConversionUtil;
|
||||
import malte0811.industrialwires.util.JouleEnergyStorage;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IWDamageSources;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialWires.blocks.IHasDummyBlocksIW;
|
||||
import malte0811.industrialWires.blocks.ISyncReceiver;
|
||||
import malte0811.industrialWires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialWires.util.Beziers;
|
||||
import malte0811.industrialWires.util.DualEnergyStorage;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -52,8 +54,10 @@ import net.minecraft.util.math.AxisAlignedBB;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -61,34 +65,35 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static malte0811.industrialwires.IndustrialWires.hasIC2;
|
||||
import static malte0811.industrialwires.util.MiscUtils.interpolate;
|
||||
import static malte0811.industrialWires.IndustrialWires.hasIC2;
|
||||
import static malte0811.industrialWires.util.MiscUtils.interpolate;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "ic2", iface = "ic2.api.energy.tile.IEnergySink"),
|
||||
@Optional.Interface(modid = "mirage", iface = "com.elytradev.mirage.lighting.IColoredLight")
|
||||
})
|
||||
public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickable, IHasDummyBlocksIW, ISyncReceiver,
|
||||
IEnergySink, IBlockBoundsIW, IDirectionalTile, IColoredLight, IEBlockInterfaces.IPlayerInteraction {
|
||||
IEnergySink, IBlockBoundsIW, IDirectionalTile, IColoredLight {
|
||||
public EnumFacing facing = EnumFacing.NORTH;
|
||||
private JouleEnergyStorage energy;
|
||||
private DualEnergyStorage energy;
|
||||
public LadderSize size;
|
||||
|
||||
public Vec3d[] controls;
|
||||
//first and last move along the "rails", only the middle points move in bezier curves
|
||||
private Vec3d[][] controlControls;
|
||||
public Vec3d[][] controlControls;
|
||||
// movement of the controls in blocks/tick
|
||||
public Vec3d[] controlMovement;
|
||||
private double t = 0;
|
||||
private int dummy = 0;
|
||||
public int dummy = 0;
|
||||
public int timeTillActive = -1;
|
||||
private double tStep = 0;
|
||||
private double consumtionJoule;
|
||||
private double consumtionEU;
|
||||
private boolean addedToIC2Net = false;
|
||||
private int soundPhase;
|
||||
private Vec3d soundPos;
|
||||
public double salt;
|
||||
|
||||
TileEntityJacobsLadder(LadderSize s) {
|
||||
public TileEntityJacobsLadder(LadderSize s) {
|
||||
size = s;
|
||||
initControl();
|
||||
}
|
||||
|
@ -103,15 +108,8 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
controlControls = new Vec3d[size.arcPoints - 2][size.movementPoints];
|
||||
controlMovement = new Vec3d[size.arcPoints];
|
||||
int sizeId = size.ordinal();
|
||||
consumtionJoule = IWConfig.HVStuff.jacobsUsageWatt[sizeId];
|
||||
energy = new JouleEnergyStorage(20 * consumtionJoule,
|
||||
40 * consumtionJoule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
Compat.loadIC2Tile.accept(this);
|
||||
consumtionEU = IWConfig.HVStuff.jacobsUsageEU[sizeId];
|
||||
energy = new DualEnergyStorage(20 * consumtionEU, 2 * consumtionEU);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,8 +119,10 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
return;
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
if ((controlControls[0][0] == null || timeTillActive == -1 || t >= 1)
|
||||
&& energy.getEnergyStoredJ() >= 2 * consumtionJoule) {
|
||||
if (hasIC2&&!addedToIC2Net) {
|
||||
addToIC2Net();
|
||||
}
|
||||
if ((controlControls[0][0] == null || timeTillActive == -1 || t >= 1) && energy.getEnergyStoredEU() >= 2 * consumtionEU) {
|
||||
for (int j = 0; j < size.movementPoints; j++) {
|
||||
double y = j * (size.height + size.extraHeight) / (double) (size.movementPoints - 1) + size.innerPointOffset;
|
||||
double width = widthFromHeight(y);
|
||||
|
@ -139,9 +139,9 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
tStep = 1D / (int) (.875 * size.tickToTop + world.rand.nextInt(size.tickToTop / 4));
|
||||
IndustrialWires.packetHandler.sendToAll(new MessageTileSyncIW(this, writeArcStarter()));
|
||||
} else if (timeTillActive == 0 && t < 1) {
|
||||
double extracted = energy.extract(consumtionJoule, 1, true);
|
||||
if (extracted >= consumtionJoule) {
|
||||
energy.extract(consumtionJoule, 1, false);
|
||||
double extracted = energy.extractEU(consumtionEU, false);
|
||||
if (extracted >= consumtionEU) {
|
||||
energy.extractEU(consumtionEU, true);
|
||||
} else {
|
||||
timeTillActive = -1 - size.delay;
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
@ -187,6 +187,12 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "ic2")
|
||||
private void addToIC2Net() {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
addedToIC2Net = true;
|
||||
}
|
||||
|
||||
private void initArc(int delay) {
|
||||
if (controlMovement == null) {
|
||||
initControl();
|
||||
|
@ -244,7 +250,6 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
return nbt;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void readArcStarter(NBTTagCompound nbt) {
|
||||
controlControls = read2DVecArray(nbt.getTagList("ctrlCtrl", 9));
|
||||
tStep = nbt.getDouble("tStep");
|
||||
|
@ -317,7 +322,6 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onSync(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("salt")) {
|
||||
salt = nbt.getDouble("salt");
|
||||
|
@ -330,7 +334,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isActive() {
|
||||
public boolean isActive() {
|
||||
if (isDummy()) {
|
||||
TileEntity master = world.getTileEntity(pos.down(dummy));
|
||||
return master instanceof TileEntityJacobsLadder && ((TileEntityJacobsLadder) master).isActive();
|
||||
|
@ -351,9 +355,8 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
e.attackEntityFrom(IWDamageSources.dmg_jacobs, IWConfig.HVStuff.jacobsBaseDmg * (size.ordinal() + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interact(@Nonnull EnumFacing side, @Nonnull EntityPlayer player,@Nonnull EnumHand hand,
|
||||
@Nonnull ItemStack heldItem, float hitX, float hitY, float hitZ) {
|
||||
public boolean onActivated(EntityPlayer player, EnumHand hand) {
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
TileEntity masterTE = dummy == 0 ? this : world.getTileEntity(pos.down(dummy));
|
||||
if (masterTE instanceof TileEntityJacobsLadder) {
|
||||
TileEntityJacobsLadder master = (TileEntityJacobsLadder) masterTE;
|
||||
|
@ -417,7 +420,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
@Override
|
||||
@Optional.Method(modid = "ic2")
|
||||
public double getDemandedEnergy() {
|
||||
return energy.getRequested(ConversionUtil.euPerJoule());
|
||||
return energy.getEURequested();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -429,7 +432,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
@Override
|
||||
@Optional.Method(modid = "ic2")
|
||||
public double injectEnergy(EnumFacing dir, double amount, double voltage) {
|
||||
return amount - energy.insert(amount, ConversionUtil.joulesPerEu(), true);
|
||||
return amount - energy.insertEU(amount, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -448,7 +451,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (hasCapability(capability, facing)) {
|
||||
if (capability == CapabilityEnergy.ENERGY) {
|
||||
return CapabilityEnergy.ENERGY.cast(energy);
|
||||
return (T) new EnergyCap();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -457,22 +460,31 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (hasIC2) {
|
||||
Compat.unloadIC2Tile.accept(this);
|
||||
removeFromIC2Net();
|
||||
}
|
||||
addedToIC2Net = false;
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (hasIC2)
|
||||
Compat.unloadIC2Tile.accept(this);
|
||||
removeFromIC2Net();
|
||||
if (world.isRemote) {
|
||||
//stop sound
|
||||
IndustrialWires.proxy.playJacobsLadderSound(this, -1, soundPos);
|
||||
}
|
||||
addedToIC2Net = false;
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "ic2")
|
||||
private void removeFromIC2Net() {
|
||||
if (!world.isRemote && addedToIC2Net) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
|
@ -533,8 +545,8 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
return false;
|
||||
}
|
||||
|
||||
private static final float[] saltColor = {1, 190 / 255F, 50 / 255F};
|
||||
private static final float[] airColor = {1, .85F, 1};
|
||||
public static final float[] saltColor = {1, 190 / 255F, 50 / 255F};
|
||||
public static final float[] airColor = {1, .85F, 1};
|
||||
|
||||
private static final int factor = 20;
|
||||
private static final double smallMin = Math.exp(-.5);
|
||||
|
@ -634,4 +646,37 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
return name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public class EnergyCap implements IEnergyStorage {
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
return (int) energy.insertIF(maxReceive, !simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
return (int) energy.getEnergyStoredIF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
return (int) energy.getMaxStoredIF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtract() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.blocks.hv;
|
||||
package malte0811.industrialWires.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
|
@ -23,25 +26,23 @@ import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
|||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.redstone.IRedstoneConnector;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.redstone.RedstoneWireNetwork;
|
||||
import blusunrize.immersiveengineering.common.IESaveData;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.*;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import com.elytradev.mirage.event.GatherLightsEvent;
|
||||
import com.elytradev.mirage.lighting.Light;
|
||||
import malte0811.industrialwires.*;
|
||||
import malte0811.industrialwires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialwires.blocks.ISyncReceiver;
|
||||
import malte0811.industrialwires.blocks.IWProperties;
|
||||
import malte0811.industrialwires.blocks.TileEntityIWMultiblock;
|
||||
import malte0811.industrialwires.hv.IMarxTarget;
|
||||
import malte0811.industrialwires.hv.MarxOreHandler;
|
||||
import malte0811.industrialwires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialwires.util.ConversionUtil;
|
||||
import malte0811.industrialwires.util.JouleEnergyStorage;
|
||||
import malte0811.industrialwires.util.MiscUtils;
|
||||
import malte0811.industrialwires.wires.MixedWireType;
|
||||
import malte0811.industrialWires.*;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialWires.blocks.ISyncReceiver;
|
||||
import malte0811.industrialWires.blocks.IWProperties;
|
||||
import malte0811.industrialWires.blocks.TileEntityIWMultiblock;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import malte0811.industrialWires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialWires.util.DualEnergyStorage;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -54,7 +55,6 @@ import net.minecraft.nbt.NBTTagDouble;
|
|||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
@ -70,11 +70,9 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
import static blusunrize.immersiveengineering.api.energy.wires.WireType.REDSTONE_CATEGORY;
|
||||
import static malte0811.industrialwires.blocks.hv.TileEntityMarx.FiringState.FIRE;
|
||||
import static malte0811.industrialwires.util.MiscUtils.offset;
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
import static malte0811.industrialwires.wires.MixedWireType.IC2_HV_CAT;
|
||||
import static malte0811.industrialWires.blocks.hv.TileEntityMarx.FiringState.FIRE;
|
||||
import static malte0811.industrialWires.util.MiscUtils.getOffset;
|
||||
import static malte0811.industrialWires.util.MiscUtils.offset;
|
||||
import static net.minecraft.item.EnumDyeColor.*;
|
||||
|
||||
/**
|
||||
|
@ -88,11 +86,15 @@ import static net.minecraft.item.EnumDyeColor.*;
|
|||
* Pink: Fine top cap voltage
|
||||
*/
|
||||
@Mod.EventBusSubscriber
|
||||
public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable, ISyncReceiver, IBlockBoundsIW, IImmersiveConnectable, IMixedConnector,
|
||||
public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable, ISyncReceiver, IBlockBoundsIW, IImmersiveConnectable, IIC2Connector,
|
||||
IRedstoneConnector {
|
||||
//Only relevant client-side.
|
||||
private static final Set<TileEntityMarx> FIRING_GENERATORS = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
|
||||
private static final String TYPE = "type";
|
||||
private static final String STAGES = "stages";
|
||||
private static final String HAS_CONN = "hasConn";
|
||||
private static final String CAP_VOLTAGES = "capVoltages";
|
||||
private double rcTimeConst;
|
||||
private double timeFactor;
|
||||
private double timeFactorBottom;
|
||||
|
@ -103,8 +105,8 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
private int stageCount = 0;
|
||||
public FiringState state = FiringState.CHARGING;
|
||||
public Discharge dischargeData;
|
||||
// Voltage=10*storedJ
|
||||
private JouleEnergyStorage storage = new JouleEnergyStorage(50_000, 20*32_000);
|
||||
// Voltage=100*storedEU
|
||||
private DualEnergyStorage storage = new DualEnergyStorage(50_000, 32_000);
|
||||
private boolean hasConnection;
|
||||
private double[] capVoltages;
|
||||
private int voltageControl = 0;
|
||||
|
@ -126,7 +128,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
out.setInteger(TYPE, type.ordinal());
|
||||
out.setInteger(STAGES, stageCount);
|
||||
out.setBoolean(HAS_CONN, hasConnection);
|
||||
storage.writeToNbt(out, ENERGY);
|
||||
storage.writeToNbt(out, ENERGY_TAG);
|
||||
NBTTagList voltages = new NBTTagList();
|
||||
if (capVoltages != null) {
|
||||
for (int i = 0; i < stageCount; i++) {
|
||||
|
@ -147,7 +149,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
for (int i = 0;i<stageCount;i++) {
|
||||
capVoltages[i] = voltages.getDoubleAt(i);
|
||||
}
|
||||
storage.readFromNBT(in.getCompoundTag(ENERGY));
|
||||
storage.readFromNBT(in.getCompoundTag(ENERGY_TAG));
|
||||
hasConnection = in.getBoolean(HAS_CONN);
|
||||
collisionAabb = null;
|
||||
renderAabb = null;
|
||||
|
@ -159,83 +161,38 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
return getPos().subtract(offset).offset(facing.getOpposite(), 3);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public IBlockState getOriginalBlock() {
|
||||
int forward = getForward();
|
||||
int right = getRight();
|
||||
int up = offset.getY();
|
||||
if (forward==0) {
|
||||
return IEObjects.blockMetalDevice0.getDefaultState().withProperty(IEObjects.blockMetalDevice0.property, BlockTypes_MetalDevice0.CAPACITOR_HV);
|
||||
return IEContent.blockMetalDevice0.getDefaultState().withProperty(IEContent.blockMetalDevice0.property, BlockTypes_MetalDevice0.CAPACITOR_HV);
|
||||
} else if (forward==-1) {
|
||||
return IEObjects.blockConnectors.getDefaultState().withProperty(IEObjects.blockConnectors.property, BlockTypes_Connector.RELAY_HV)
|
||||
return IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.RELAY_HV)
|
||||
.withProperty(IEProperties.FACING_ALL, facing);
|
||||
} else if (forward==4&&up==0&&right==1) {
|
||||
return IEObjects.blockStorage.getDefaultState().withProperty(IEObjects.blockStorage.property, BlockTypes_MetalsIE.STEEL);
|
||||
return IEContent.blockStorage.getDefaultState().withProperty(IEContent.blockStorage.property, BlockTypes_MetalsIE.STEEL);
|
||||
} else if (forward>0) {
|
||||
if ((right==0&&up==0)||(right==1&&up==stageCount-1)) {
|
||||
return IEObjects.blockMetalDecoration1.getDefaultState().withProperty(IEObjects.blockMetalDecoration1.property, BlockTypes_MetalDecoration1.STEEL_FENCE);
|
||||
return IEContent.blockMetalDecoration1.getDefaultState().withProperty(IEContent.blockMetalDecoration1.property, BlockTypes_MetalDecoration1.STEEL_FENCE);
|
||||
} else {
|
||||
return IEObjects.blockMetalDecoration2.getDefaultState().withProperty(IEObjects.blockMetalDecoration2.property, BlockTypes_MetalDecoration2.STEEL_WALLMOUNT)
|
||||
return IEContent.blockMetalDecoration2.getDefaultState().withProperty(IEContent.blockMetalDecoration2.property, BlockTypes_MetalDecoration2.STEEL_WALLMOUNT)
|
||||
.withProperty(IEProperties.INT_4, 1-right).withProperty(IEProperties.FACING_ALL, facing.getOpposite());
|
||||
}
|
||||
} else if (forward==-2) {
|
||||
return IEObjects.blockMetalDecoration0.getDefaultState().withProperty(IEObjects.blockMetalDecoration0.property, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING);
|
||||
return IEContent.blockMetalDecoration0.getDefaultState().withProperty(IEContent.blockMetalDecoration0.property, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING);
|
||||
} else if (right==0) {
|
||||
return IEObjects.blockConnectors.getDefaultState().withProperty(IEObjects.blockConnectors.property, BlockTypes_Connector.CONNECTOR_REDSTONE)
|
||||
return IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.CONNECTOR_REDSTONE)
|
||||
.withProperty(IEProperties.FACING_ALL, facing);
|
||||
} else {
|
||||
return IEObjects.blockConnectors.getDefaultState().withProperty(IEObjects.blockConnectors.property, BlockTypes_Connector.CONNECTOR_HV)
|
||||
return IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.CONNECTOR_HV)
|
||||
.withProperty(IEProperties.FACING_ALL, facing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disassemble() {
|
||||
boolean active = formed && !world.isRemote;
|
||||
IndustrialWires.logger.info("Calling disassemble for {}, active {}", pos, active);
|
||||
super.disassemble();
|
||||
if (active) {
|
||||
final int forward = -1;
|
||||
BlockPos master = pos.subtract(offset);
|
||||
ItemStack coil = new ItemStack(IEObjects.itemWireCoil, 1, 2);
|
||||
WireType type = WireType.STEEL;
|
||||
TargetingInfo dummy = new TargetingInfo(EnumFacing.DOWN, 0, 0, 0);
|
||||
for (int up = 0; up < stageCount - 1; ++up) {
|
||||
for (int right = 0; right < 2; ++right) {
|
||||
BlockPos lowerPos = offset(master, facing, mirrored, right, forward, up);
|
||||
BlockPos upperPos = lowerPos.up();
|
||||
IndustrialWires.logger.info("Lower: {}, upper: {}, master: {}", lowerPos, upperPos, master);
|
||||
TileEntity lowerTE = world.getTileEntity(lowerPos);
|
||||
if (!(lowerTE instanceof IImmersiveConnectable)) {
|
||||
world.spawnEntity(new EntityItem(world, lowerPos.getX() + .5, lowerPos.getY() + .5,
|
||||
lowerPos.getZ() + .5, coil));
|
||||
continue;
|
||||
}
|
||||
TileEntity upperTE = world.getTileEntity(upperPos);
|
||||
if (!(upperTE instanceof IImmersiveConnectable)) {
|
||||
world.spawnEntity(new EntityItem(world, lowerPos.getX() + .5, lowerPos.getY() + .5,
|
||||
lowerPos.getZ() + .5, coil));
|
||||
continue;
|
||||
}
|
||||
IImmersiveConnectable lowerIIC = (IImmersiveConnectable) lowerTE;
|
||||
IImmersiveConnectable upperIIC = (IImmersiveConnectable) upperTE;
|
||||
ImmersiveNetHandler.Connection conn = ImmersiveNetHandler.INSTANCE.addAndGetConnection(world,
|
||||
lowerPos, upperPos, 1, type);
|
||||
lowerIIC.connectCable(type, dummy, upperIIC);
|
||||
upperIIC.connectCable(type, dummy, lowerIIC);
|
||||
ImmersiveNetHandler.INSTANCE.addBlockData(world, conn);
|
||||
IESaveData.setDirty(world.provider.getDimension());
|
||||
lowerTE.markDirty();
|
||||
IBlockState state = world.getBlockState(lowerPos);
|
||||
world.notifyBlockUpdate(lowerPos, state, state, 3);
|
||||
upperTE.markDirty();
|
||||
state = world.getBlockState(upperPos);
|
||||
world.notifyBlockUpdate(upperPos, state, state, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
ApiUtils.checkForNeedlessTicking(this);
|
||||
|
@ -268,7 +225,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
//charge bottom cap from storage
|
||||
double setVoltage = MAX_VOLTAGE * voltageControl / 255F;
|
||||
double u0 = Math.min(setVoltage, 10 * storage.getEnergyStoredJ());
|
||||
double u0 = Math.min(setVoltage, 100 * storage.getEnergyStoredEU());
|
||||
if (u0 < 0) {
|
||||
u0 = 0;
|
||||
}
|
||||
|
@ -277,8 +234,8 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
double tmp = u0 - (u0 - oldBottomVoltage) * timeFactorBottom;
|
||||
double energyUsed = .5 * (tmp * tmp - oldBottomVoltage * oldBottomVoltage) * CAPACITANCE;
|
||||
if (energyUsed > 0 && storage.extract(energyUsed, 1, true) == energyUsed) {// energyUsed can be negative when discharging the caps
|
||||
storage.extract(energyUsed, 1, false);
|
||||
if (energyUsed > 0 && storage.extractEU(energyUsed, false) == energyUsed) {// energyUsed can be negative when discharging the caps
|
||||
storage.extractEU(energyUsed, true);
|
||||
capVoltages[0] = tmp;
|
||||
} else if (energyUsed <= 0) {
|
||||
capVoltages[0] = tmp;
|
||||
|
@ -293,7 +250,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
state = FiringState.NEXT_TICK;
|
||||
}
|
||||
}
|
||||
leftover = storage.getMaxInPerTick();
|
||||
leftover = storage.getMaxInputIF();
|
||||
}
|
||||
|
||||
private void fire() {
|
||||
|
@ -329,11 +286,12 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
|
||||
private void handleOreProcessing(double energyStored) {
|
||||
BlockPos bottom = getBottomElectrode();
|
||||
List<BlockPos> toBreak = new ArrayList<>(stageCount - 2);
|
||||
Vec3d origin = new Vec3d(bottom).addVector(.5, 1, .5);
|
||||
Set<BlockPos> toBreak = new HashSet<>(stageCount-2);
|
||||
int ores = 0;
|
||||
for (int i = 1;i<stageCount-1;i++) {
|
||||
BlockPos blockHere = bottom.up(i);
|
||||
if (!world.isAirBlock(blockHere)) {
|
||||
if (!world.isAirBlock(blockHere) && canBreak(blockHere)) {
|
||||
toBreak.add(blockHere);
|
||||
ores++;
|
||||
}
|
||||
|
@ -346,12 +304,6 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
continue;
|
||||
}
|
||||
if (!world.isAirBlock(here)) {
|
||||
TileEntity te = world.getTileEntity(here);
|
||||
if (te instanceof IMarxTarget) {
|
||||
if (((IMarxTarget) te).onHit(energyPerOre, this)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ItemStack[] out = MarxOreHandler.getYield(world, here, energyPerOre);
|
||||
for (ItemStack stack : out) {
|
||||
EntityItem item = new EntityItem(world, here.getX() + .5, here.getY() + .5, here.getZ() + .5, stack);
|
||||
|
@ -372,7 +324,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
double tinnitusDistSqu = Math.sqrt(energyStored)/50;
|
||||
Vec3d v0 = getMiddle();
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(v0.x, v0.y, v0.z, v0.x, v0.y, v0.z);
|
||||
aabb = aabb.grow(0, stageCount / 2. - 1, 0);
|
||||
aabb = aabb.grow(0, stageCount/2-1,0);
|
||||
aabb = aabb.grow(tinnitusDistSqu);
|
||||
List<Entity> fools = world.getEntitiesWithinAABB(Entity.class, aabb);
|
||||
damageDistSqu *= damageDistSqu;
|
||||
|
@ -397,7 +349,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
if (distSqu<=tinnitusDistSqu && entity instanceof EntityPlayer) {
|
||||
ItemStack helmet = ((EntityPlayer) entity).inventory.armorInventory.get(3);
|
||||
boolean earMuff = helmet.getItem()==IEObjects.itemEarmuffs;
|
||||
boolean earMuff = helmet.getItem()==IEContent.itemEarmuffs;
|
||||
if (!earMuff&&helmet.hasTagCompound()) {
|
||||
earMuff = helmet.getTagCompound().hasKey("IE:Earmuffs");
|
||||
}
|
||||
|
@ -414,6 +366,16 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
}
|
||||
|
||||
//checks whether the given pos can't be broken because it is part of the generator
|
||||
private boolean canBreak(BlockPos pos) {
|
||||
BlockPos dischargePos = offset(this.pos, facing, mirrored, 1, 3, 0);
|
||||
Vec3i offset = getOffset(dischargePos, facing, mirrored, pos);
|
||||
if (offset.getZ()<1||offset.getZ()>=stageCount-1) {
|
||||
return false;
|
||||
}
|
||||
return Math.abs(offset.getX())>Math.abs(offset.getY());
|
||||
}
|
||||
|
||||
private int getRSSignalFromVoltage(double voltage) {
|
||||
return (int) (Math.round(255 * voltage / MAX_VOLTAGE)&0xff);
|
||||
}
|
||||
|
@ -558,7 +520,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
public int outputEnergy(int amount, boolean simulate, int energyType) {
|
||||
TileEntityMarx master = master(this);
|
||||
if (master!=null && amount>0) {
|
||||
double ret = master.storage.insert(amount, ConversionUtil.joulesPerIf(), simulate, master.leftover);
|
||||
double ret = master.storage.insertIF(amount, master.leftover, !simulate);
|
||||
master.leftover -= ret;
|
||||
return (int) ret;
|
||||
} else {
|
||||
|
@ -567,14 +529,12 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public double insertEnergy(double joules, boolean simulate) {
|
||||
public double insertEnergy(double eu, boolean simulate) {
|
||||
TileEntityMarx master = master(this);
|
||||
if (master!=null) {
|
||||
double ret = master.storage.insert(joules, 1, simulate, master.leftover);
|
||||
if (!simulate) {
|
||||
master.leftover -= ret;
|
||||
}
|
||||
return joules -ret;
|
||||
double ret = master.storage.insertEU(eu, master.leftover, !simulate);
|
||||
master.leftover -= ret;
|
||||
return eu-ret;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -585,34 +545,31 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) {
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target) {
|
||||
if (hasConnection) {
|
||||
return false;
|
||||
}
|
||||
if (getRight()==0) {
|
||||
return REDSTONE_CATEGORY.equals(cableType.getCategory());
|
||||
return cableType==WireType.REDSTONE;
|
||||
} else {
|
||||
return WireType.HV_CATEGORY.equals(cableType.getCategory())|| IC2_HV_CAT.equals(cableType.getCategory());
|
||||
return cableType==WireType.STEEL||cableType== IC2Wiretype.IC2_TYPES[3];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectCable(WireType cableType, TargetingInfo target, IImmersiveConnectable other) {
|
||||
hasConnection = true;
|
||||
if (WireType.REDSTONE_CATEGORY.equals(cableType.getCategory()))
|
||||
RedstoneWireNetwork.updateConnectors(pos, world, getNetwork());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WireType getCableLimiter(TargetingInfo target) {
|
||||
return getRight()==0?WireType.REDSTONE:MixedWireType.HV;
|
||||
return getRight()==0?WireType.REDSTONE:IC2Wiretype.IC2_TYPES[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowEnergyToPass(ImmersiveNetHandler.Connection con) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -631,7 +588,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection con) {
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
Matrix4 transf = getBaseTransform();
|
||||
if (getRight()==0) {
|
||||
return transf.apply(new Vec3d(.5, .5, 7/16D));
|
||||
|
@ -640,19 +597,24 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection con) {
|
||||
return getRaytraceOffset(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validate()
|
||||
{
|
||||
super.validate();
|
||||
if (!world.isRemote)
|
||||
ApiUtils.addFutureServerTask(world, () -> ImmersiveNetHandler.INSTANCE.onTEValidated(this));
|
||||
ImmersiveNetHandler.INSTANCE.resetCachedIndirectConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
if (world.isRemote && !IndustrialWires.proxy.isSingleplayer())
|
||||
if (world.isRemote)
|
||||
ImmersiveNetHandler.INSTANCE.clearConnectionsOriginatingFrom(pos, world);
|
||||
}
|
||||
|
||||
|
@ -746,16 +708,16 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
.radius(5);
|
||||
List<Light> toAdd = new ArrayList<>(te.stageCount*2-3);
|
||||
if (te.dischargeData!=null&&te.dischargeData.energy>0) {
|
||||
toAdd.add(builder.pos(origin.add(0, 0, 0)).build());
|
||||
toAdd.add(builder.pos(origin.add(0, te.stageCount / 2, 0)).build());
|
||||
toAdd.add(builder.pos(origin.add(0, te.stageCount - 2, 0)).build());
|
||||
toAdd.add(builder.pos(origin.addVector(0, 0, 0)).build());
|
||||
toAdd.add(builder.pos(origin.addVector(0, te.stageCount/2, 0)).build());
|
||||
toAdd.add(builder.pos(origin.addVector(0, te.stageCount-2, 0)).build());
|
||||
}
|
||||
origin = new Vec3d(offset(te.pos, te.facing, te.mirrored, 1, 0, 0))
|
||||
.add(0, .75, 0)
|
||||
.addVector(0, .75, 0)
|
||||
.add(new Vec3d(te.facing.getDirectionVec()).scale(.25));
|
||||
builder.radius(.5F);
|
||||
for (int i = 0;i<te.stageCount-1;i+=te.stageCount/5) {
|
||||
toAdd.add(builder.pos(origin.add(0, i, 0)).build());
|
||||
toAdd.add(builder.pos(origin.addVector(0, i, 0)).build());
|
||||
}
|
||||
event.getLightList().addAll(toAdd);
|
||||
}
|
||||
|
@ -800,12 +762,12 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
Vec3d diff = vertices[max].subtract(vertices[min]);
|
||||
Vec3d v0 = diff.crossProduct(side);
|
||||
transform.setIdentity();
|
||||
double diffLength = diff.length();
|
||||
double diffLength = diff.lengthVector();
|
||||
double noise = Math.sqrt(diffLength)*rand.nextDouble()*1/(1+Math.abs(stageCount/2.0-toGenerate))*.75;
|
||||
if ((max-min)%2==1) {
|
||||
noise *= (toGenerate-min)/(double)(max-min);
|
||||
}
|
||||
v0 = v0.scale((float) (noise / v0.length()));
|
||||
v0 = v0.scale((float) (noise/v0.lengthVector()));
|
||||
diff = diff.scale(1/diffLength);
|
||||
transform.rotate(Math.PI*2*rand.nextDouble(), diff.x, diff.y, diff.z);
|
||||
Vec3d center = vertices[max].add(vertices[min]).scale(.5);
|
|
@ -1,27 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks.wire;
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import malte0811.industrialwires.IWConfig;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.BlockIWBase;
|
||||
import malte0811.industrialwires.blocks.IMetaEnum;
|
||||
import malte0811.industrialwires.util.ConversionUtil;
|
||||
import malte0811.industrialwires.wires.MixedWireType;
|
||||
import net.minecraft.block.Block;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
@ -40,8 +40,6 @@ import net.minecraft.world.IBlockAccess;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -49,7 +47,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
||||
public static final PropertyEnum<BlockTypes_IC2_Connector> TYPE = PropertyEnum.create("type", BlockTypes_IC2_Connector.class);
|
||||
private static final PropertyEnum<BlockTypes_IC2_Connector> type = PropertyEnum.create("type", BlockTypes_IC2_Connector.class);
|
||||
public static final String NAME = "ic2_connector";
|
||||
|
||||
public BlockIC2Connector() {
|
||||
|
@ -60,11 +58,11 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos posNeighbor) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof TileEntityIC2ConnectorTin) {
|
||||
TileEntityIC2ConnectorTin connector = (TileEntityIC2ConnectorTin) te;
|
||||
if (world.isAirBlock(pos.offset(connector.getFacing()))) {
|
||||
if (world.isAirBlock(pos.offset(connector.facing))) {
|
||||
this.dropBlockAsItem(connector.getWorld(), pos, world.getBlockState(pos), 0);
|
||||
connector.getWorld().setBlockToAir(pos);
|
||||
}
|
||||
|
@ -73,7 +71,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (int i = 0; i < TYPE.getAllowedValues().size(); i++) {
|
||||
for (int i = 0; i < type.getAllowedValues().size(); i++) {
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +88,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
protected IProperty<?>[] getProperties() {
|
||||
return new IProperty[]{TYPE, IEProperties.FACING_ALL};
|
||||
return new IProperty[]{type, IEProperties.FACING_ALL};
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -107,7 +105,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return super.getStateFromMeta(meta).withProperty(TYPE, BlockTypes_IC2_Connector.values()[meta]);
|
||||
return super.getStateFromMeta(meta).withProperty(type, BlockTypes_IC2_Connector.values()[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -122,15 +120,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
|
||||
TileEntityIC2ConnectorTin base = getBaseTE(state.getValue(TYPE));
|
||||
if (base!=null) {
|
||||
base.setFacing(state.getValue(IEProperties.FACING_ALL));
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
private TileEntityIC2ConnectorTin getBaseTE(BlockTypes_IC2_Connector type) {
|
||||
switch (type) {
|
||||
switch (state.getValue(type)) {
|
||||
case TIN_CONN:
|
||||
return new TileEntityIC2ConnectorTin(false);
|
||||
case TIN_RELAY:
|
||||
|
@ -156,16 +146,12 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag advanced) {
|
||||
super.addInformation(stack, world, tooltip, advanced);
|
||||
if (!stack.isEmpty() && stack.getMetadata() % 2 == 0) {
|
||||
int type = stack.getMetadata() / 2;
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.power_tier", (type%5) + 1));
|
||||
MixedWireType wire = MixedWireType.ALL[type];
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.energy_per_tick",
|
||||
wire.getIORate()*ConversionUtil.euPerJoule(),
|
||||
wire.getIORate()*ConversionUtil.ifPerJoule()*IWConfig.wireRatio));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.power_tier", type + 1));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.eu_per_tick", IC2Wiretype.IC2_TYPES[type].getTransferRate() / 8));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,6 +191,6 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(TYPE).ordinal();
|
||||
return state.getValue(type).ordinal();
|
||||
}
|
||||
}
|
|
@ -1,18 +1,21 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks.wire;
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockIEBase.IBlockEnum;
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
public final class DummyTEs {
|
||||
public static class TinDummy extends TileEntityIC2ConnectorTin {
|
||||
@Override
|
||||
public void update() {
|
||||
TileEntityIC2ConnectorTin newTe = getRaw();
|
||||
newTe.inBuffer = inBuffer;
|
||||
newTe.outBuffer = outBuffer;
|
||||
newTe.maxToNet = maxToNet;
|
||||
newTe.maxToMachine = maxToMachine;
|
||||
newTe.relay = relay;
|
||||
newTe.facing = facing;
|
||||
world.setTileEntity(pos, newTe);
|
||||
}
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorTin();
|
||||
}
|
||||
}
|
||||
public static class CopperDummy extends TinDummy {
|
||||
@Override
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorCopper();
|
||||
}
|
||||
}
|
||||
public static class GoldDummy extends TinDummy {
|
||||
@Override
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorGold();
|
||||
}
|
||||
}
|
||||
public static class HVDummy extends TinDummy {
|
||||
@Override
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorHV();
|
||||
}
|
||||
}
|
||||
public static class GlassDummy extends TinDummy {
|
||||
@Override
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorGlass();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +1,42 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks.wire;
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import static malte0811.industrialwires.wires.MixedWireType.COPPER_IC2;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
|
||||
public class TileEntityIC2ConnectorCopper extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorCopper(boolean rel) {
|
||||
super(rel, COPPER_IC2, 2, .5, .5);
|
||||
super(rel);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorCopper() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
{
|
||||
tier = 2;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[1].getTransferRate() / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[1];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +1,40 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.blocks.wire;
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import static malte0811.industrialwires.wires.MixedWireType.GLASS;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
|
||||
public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorTin {
|
||||
public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorHV {
|
||||
public TileEntityIC2ConnectorGlass(boolean rel) {
|
||||
super(rel, GLASS, 5, .875, .75);
|
||||
super(rel);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorGlass() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
{
|
||||
tier = 5;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[4].getTransferRate() / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[4];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class TileEntityIC2ConnectorGold extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorGold(boolean rel) {
|
||||
super(rel);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorGold() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 3;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[2].getTransferRate() / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .125, .5 + side.getFrontOffsetY() * .125, .5 + side.getFrontOffsetZ() * .125);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
double conRadius = con.cableType.getRenderDiameter() / 2;
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * (.0625 - conRadius), .5 + side.getFrontOffsetY() * (.0625 - conRadius), .5 + side.getFrontOffsetZ() * (.0625 - conRadius));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class TileEntityIC2ConnectorHV extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorHV(boolean rel) {
|
||||
super(rel);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorHV() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 4;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[3].getTransferRate() / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
if (relay) {
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .4375, .5 + side.getFrontOffsetY() * .4375, .5 + side.getFrontOffsetZ() * .4375);
|
||||
} else {
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .3125, .5 + side.getFrontOffsetY() * .3125, .5 + side.getFrontOffsetZ() * .3125);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
double conRadius = con.cableType.getRenderDiameter() / 2;
|
||||
if (relay) {
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * (.375 - conRadius), .5 + side.getFrontOffsetY() * (.375 - conRadius), .5 + side.getFrontOffsetZ() * (.375 - conRadius));
|
||||
} else {
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * (.25 - conRadius), .5 + side.getFrontOffsetY() * (.25 - conRadius), .5 + side.getFrontOffsetZ() * (.25 - conRadius));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,412 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.api.TargetingInfo;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.AbstractConnection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergyAcceptor;
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import malte0811.industrialWires.IIC2Connector;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.api.power.IEnergyInterfaceTile;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "ic2"),
|
||||
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "ic2")
|
||||
})
|
||||
public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable implements IEnergySource, IEnergySink, IDirectionalTile,
|
||||
ITickable, IIC2Connector, IBlockBoundsIW {
|
||||
EnumFacing facing = EnumFacing.NORTH;
|
||||
boolean relay;
|
||||
private boolean first = true;
|
||||
//IC2 net to IE net buffer
|
||||
double inBuffer = 0;
|
||||
double maxToNet = 0;
|
||||
//IE net to IC2 net buffer
|
||||
double outBuffer = 0;
|
||||
double maxToMachine = 0;
|
||||
double maxStored = IC2Wiretype.IC2_TYPES[0].getTransferRate() / 8;
|
||||
int tier = 1;
|
||||
|
||||
TileEntityIC2ConnectorTin(boolean rel) {
|
||||
relay = rel;
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorTin() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (first) {
|
||||
if (!world.isRemote&& IndustrialWires.hasIC2)
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
first = false;
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
if (inBuffer > .1) {
|
||||
transferPower();
|
||||
}
|
||||
if (outBuffer>.1&&IndustrialWires.hasTechReborn) {
|
||||
TileEntity output = Utils.getExistingTileEntity(world, pos.offset(facing));
|
||||
if (output instanceof IEnergyInterfaceTile) {
|
||||
IEnergyInterfaceTile out = (IEnergyInterfaceTile) output;
|
||||
if (out.canAcceptEnergy(facing.getOpposite())) {
|
||||
outBuffer -= out.addEnergy(Math.min(outBuffer, maxToMachine));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void transferPower() {
|
||||
Set<AbstractConnection> conns = new HashSet<>(ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world));
|
||||
Map<AbstractConnection, Pair<IIC2Connector, Double>> maxOutputs = new HashMap<>();
|
||||
double outputMax = Math.min(inBuffer, maxToNet);
|
||||
double sum = 0;
|
||||
for (AbstractConnection c : conns) {
|
||||
IImmersiveConnectable iic = ApiUtils.toIIC(c.end, world);
|
||||
if (iic instanceof IIC2Connector) {
|
||||
double tmp = outputMax - ((IIC2Connector) iic).insertEnergy(outputMax, true);
|
||||
if (tmp > .00000001) {
|
||||
maxOutputs.put(c, new ImmutablePair<>((IIC2Connector) iic, tmp));
|
||||
sum += tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sum < .0001) {
|
||||
return;
|
||||
}
|
||||
final double oldInBuf = outputMax;
|
||||
HashMap<Connection, Integer> transferedPerConn = ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension());
|
||||
for (AbstractConnection c : maxOutputs.keySet()) {
|
||||
Pair<IIC2Connector, Double> p = maxOutputs.get(c);
|
||||
double out = oldInBuf * p.getRight() / sum;
|
||||
double loss = getAverageLossRate(c);
|
||||
double inserted = out - p.getLeft().insertEnergy(out - loss, false);
|
||||
inBuffer -= inserted;
|
||||
float intermediaryLoss = 0;
|
||||
HashSet<IImmersiveConnectable> passedConnectors = new HashSet<>();
|
||||
double energyAtConn = inserted + loss;
|
||||
for (Connection sub : c.subConnections) {
|
||||
int transferredPerCon = transferedPerConn.getOrDefault(sub, 0);
|
||||
energyAtConn -= sub.cableType.getLossRatio() * sub.length;
|
||||
ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension()).put(sub, (int) (transferredPerCon + energyAtConn));
|
||||
IImmersiveConnectable subStart = ApiUtils.toIIC(sub.start, world);
|
||||
IImmersiveConnectable subEnd = ApiUtils.toIIC(sub.end, world);
|
||||
if (subStart != null && passedConnectors.add(subStart))
|
||||
subStart.onEnergyPassthrough((int) (inserted - inserted * intermediaryLoss));
|
||||
if (subEnd != null && passedConnectors.add(subEnd))
|
||||
subEnd.onEnergyPassthrough((int) (inserted - inserted * intermediaryLoss));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double getAverageLossRate(AbstractConnection conn) {
|
||||
double f = 0;
|
||||
for (Connection c : conn.subConnections) {
|
||||
f += c.length * c.cableType.getLossRatio();
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
//Input through the net
|
||||
@Override
|
||||
public double insertEnergy(double eu, boolean simulate) {
|
||||
final double insert = Math.min(maxStored - outBuffer, eu);
|
||||
if (insert > 0) {
|
||||
if (outBuffer < maxToMachine) {
|
||||
maxToMachine = outBuffer;
|
||||
}
|
||||
if (eu > maxToMachine) {
|
||||
maxToMachine = eu;
|
||||
}
|
||||
}
|
||||
if (!simulate) {
|
||||
outBuffer += insert;
|
||||
}
|
||||
return eu - insert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (!world.isRemote && !first)
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
first = true;
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
if (!world.isRemote && !first)
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
first = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .0625, .5 + side.getFrontOffsetY() * .0625, .5 + side.getFrontOffsetZ() * .0625);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
double conRadius = con.cableType.getRenderDiameter() / 2;
|
||||
return new Vec3d(.5 - conRadius * side.getFrontOffsetX(), .5 - conRadius * side.getFrontOffsetY(), .5 - conRadius * side.getFrontOffsetZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnergyOutput() {
|
||||
return !relay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target) {
|
||||
return (limitType == null || (this.isRelay() && limitType == cableType)) && canConnect(cableType);
|
||||
}
|
||||
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRelay() {
|
||||
return relay;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing side) {
|
||||
return !relay && side == facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing side) {
|
||||
return !relay && side == facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public double getDemandedEnergy() {
|
||||
double ret = maxStored + .5 - inBuffer;
|
||||
if (ret < .1)
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public int getSinkTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
|
||||
if (inBuffer < maxStored) {
|
||||
addToIn(amount);
|
||||
markDirty();
|
||||
return 0;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public double getOfferedEnergy() {
|
||||
return Math.min(maxToMachine, outBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public void drawEnergy(double amount) {
|
||||
outBuffer -= amount;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public int getSourceTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
private void addToIn(double amount) {
|
||||
if (inBuffer < maxToNet) {
|
||||
maxToNet = inBuffer;
|
||||
}
|
||||
inBuffer += amount;
|
||||
if (amount > maxToNet) {
|
||||
maxToNet = amount;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) {
|
||||
super.readCustomNBT(nbt, descPacket);
|
||||
facing = EnumFacing.getFront(nbt.getInteger("facing"));
|
||||
relay = nbt.getBoolean("relay");
|
||||
inBuffer = nbt.getDouble("inBuffer");
|
||||
outBuffer = nbt.getDouble("outBuffer");
|
||||
if (nbt.hasKey("maxToNet")) {
|
||||
maxToNet = nbt.getDouble("maxToNet");
|
||||
} else {
|
||||
maxToNet = inBuffer;
|
||||
}
|
||||
if (nbt.hasKey("maxToMachine")) {
|
||||
maxToMachine = nbt.getDouble("maxToMachine");
|
||||
} else {
|
||||
maxToMachine = outBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) {
|
||||
super.writeCustomNBT(nbt, descPacket);
|
||||
nbt.setInteger("facing", facing.getIndex());
|
||||
nbt.setBoolean("relay", relay);
|
||||
nbt.setDouble("inBuffer", inBuffer);
|
||||
nbt.setDouble("outBuffer", outBuffer);
|
||||
nbt.setDouble("maxToNet", maxToNet);
|
||||
nbt.setDouble("maxToMachine", maxToMachine);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(@Nonnull EnumFacing facing) {
|
||||
this.facing = facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFacingLimitation() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirrorFacingOnPlacement(@Nonnull EntityLivingBase placer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHammerRotate(@Nonnull EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull EntityLivingBase entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
float length = this instanceof TileEntityIC2ConnectorHV ? (relay ? .875f : .75f) : this instanceof TileEntityIC2ConnectorGold ? .5625f : .5f;
|
||||
float wMin = .3125f;
|
||||
float wMax = .6875f;
|
||||
switch (facing.getOpposite()) {
|
||||
case UP:
|
||||
return new AxisAlignedBB(wMin, 0, wMin, wMax, length, wMax);
|
||||
case DOWN:
|
||||
return new AxisAlignedBB(wMin, 1 - length, wMin, wMax, 1, wMax);
|
||||
case SOUTH:
|
||||
return new AxisAlignedBB(wMin, wMin, 0, wMax, wMax, length);
|
||||
case NORTH:
|
||||
return new AxisAlignedBB(wMin, wMin, 1 - length, wMax, wMax, 1);
|
||||
case EAST:
|
||||
return new AxisAlignedBB(0, wMin, wMin, length, wMax, wMax);
|
||||
case WEST:
|
||||
return new AxisAlignedBB(1 - length, wMin, wMin, 1, wMax, wMax);
|
||||
}
|
||||
return new AxisAlignedBB(0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* regarding equals+hashCode
|
||||
* TE's are considered equal if they have the same pos+dimension id
|
||||
* This is necessary to work around a weird bug causing a lot of log spam (100GB and above are well possible).
|
||||
* For further information see #1 (https://github.com/malte0811/IndustrialWires/issues/1)
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int ret = world.provider.getDimension();
|
||||
ret = 31 * ret + pos.hashCode();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof TileEntityIC2ConnectorTin)) {
|
||||
return false;
|
||||
}
|
||||
if (obj.getClass() != getClass()) {
|
||||
return false;
|
||||
}
|
||||
TileEntityIC2ConnectorTin te = (TileEntityIC2ConnectorTin) obj;
|
||||
if (!te.pos.equals(pos)) {
|
||||
return false;
|
||||
}
|
||||
if (te.world.provider.getDimension() != world.provider.getDimension()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRotate(@Nonnull EnumFacing axis) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,44 +1,43 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.client;
|
||||
package malte0811.industrialWires.client;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import blusunrize.immersiveengineering.api.Lib;
|
||||
import blusunrize.immersiveengineering.client.ClientUtils;
|
||||
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.BlockIWBase;
|
||||
import malte0811.industrialwires.blocks.IMetaEnum;
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialwires.blocks.hv.BlockHVMultiblocks;
|
||||
import malte0811.industrialwires.client.panelmodel.PanelModel;
|
||||
import malte0811.industrialwires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialwires.items.ItemIC2Coil;
|
||||
import malte0811.industrialwires.items.ItemKey;
|
||||
import malte0811.industrialwires.items.ItemPanelComponent;
|
||||
import malte0811.industrialwires.mech_mb.MechMBPart;
|
||||
import malte0811.industrialwires.wires.MixedWireType;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.blocks.hv.BlockHVMultiblocks;
|
||||
import malte0811.industrialWires.client.panelmodel.PanelModel;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.items.ItemKey;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -46,20 +45,16 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.ScreenShotHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import net.minecraftforge.client.event.*;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
|
@ -67,13 +62,9 @@ import javax.annotation.Nonnull;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static malte0811.industrialwires.client.render.TileRenderMechMB.BASE_MODELS;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = IndustrialWires.MODID, value = Side.CLIENT)
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientEventHandler {
|
||||
public static boolean shouldScreenshot = false;
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
@SubscribeEvent
|
||||
public static void renderOverlayPost(RenderGameOverlayEvent.Post e) {
|
||||
if (ClientUtils.mc().player != null && e.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
|
||||
EntityPlayer player = ClientUtils.mc().player;
|
||||
|
@ -82,17 +73,10 @@ public class ClientEventHandler {
|
|||
if (!player.getHeldItem(hand).isEmpty()) {
|
||||
ItemStack equipped = player.getHeldItem(hand);
|
||||
if (OreDictionary.itemMatches(new ItemStack(IndustrialWires.coil, 1, OreDictionary.WILDCARD_VALUE), equipped, false)) {
|
||||
MixedWireType type = MixedWireType.ALL[equipped.getItemDamage()];
|
||||
IC2Wiretype type = IC2Wiretype.IC2_TYPES[equipped.getItemDamage()];
|
||||
int color = type.getColour(null);
|
||||
final int threshold = 0x40-1;
|
||||
for (int i = 0;i<3;i++) {
|
||||
if (((color>>(8*i))&255)<threshold) {
|
||||
color |= threshold<<(8*i);
|
||||
}
|
||||
}
|
||||
String s = I18n.format(IndustrialWires.MODID + ".desc.wireLength", ItemIC2Coil.getLength(equipped));
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth() / 2 - ClientUtils.font().getStringWidth(s) / 2,
|
||||
e.getResolution().getScaledHeight() - GuiIngameForge.left_height - 40, color, true);
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth() / 2 - ClientUtils.font().getStringWidth(s) / 2, e.getResolution().getScaledHeight() - GuiIngameForge.left_height - 40, color, true);
|
||||
if (ItemNBTHelper.hasKey(equipped, "linkingPos")) {
|
||||
int[] link = ItemNBTHelper.getIntArray(equipped, "linkingPos");
|
||||
if (link != null && link.length > 3) {
|
||||
|
@ -108,8 +92,7 @@ public class ClientEventHandler {
|
|||
if (length * length < distSquared) {
|
||||
color = 0xdd3333;
|
||||
}
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth() / 2 - ClientUtils.font().getStringWidth(s) / 2,
|
||||
e.getResolution().getScaledHeight() - GuiIngameForge.left_height - 20, color, true);
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth() / 2 - ClientUtils.font().getStringWidth(s) / 2, e.getResolution().getScaledHeight() - GuiIngameForge.left_height - 20, color, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +109,7 @@ public class ClientEventHandler {
|
|||
TileEntityPanel panel = (TileEntityPanel) tile;
|
||||
Pair<PanelComponent, RayTraceResult> pc = panel.getSelectedComponent(Minecraft.getMinecraft().player, event.getTarget().hitVec, true);
|
||||
if (pc != null) {
|
||||
pc.getLeft().renderBox();
|
||||
pc.getLeft().renderBox(panel);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
@ -188,32 +171,4 @@ public class ClientEventHandler {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public static void renderWorldLastLow(RenderWorldLastEvent ev) {
|
||||
if (shouldScreenshot) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ITextComponent comp = ScreenShotHelper.saveScreenshot(mc.gameDir, mc.displayWidth, mc.displayHeight, mc.getFramebuffer());//TODO
|
||||
mc.player.sendMessage(comp);
|
||||
shouldScreenshot = false;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onTextureStitch(TextureStitchEvent event) {
|
||||
for (MechMBPart type:MechMBPart.INSTANCES.values()) {
|
||||
ResourceLocation loc = type.getRotatingBaseModel();
|
||||
try {
|
||||
IModel model = ModelLoaderRegistry.getModel(loc);
|
||||
if (model instanceof OBJModel) {
|
||||
model = model.process(ImmutableMap.of("flip-v", "true"));
|
||||
}
|
||||
model.getTextures().forEach((rl)->event.getMap().registerSprite(rl));
|
||||
IBakedModel b = model.bake(model.getDefaultState(), DefaultVertexFormats.BLOCK, (rl)->Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(rl.toString()));
|
||||
BASE_MODELS.put(loc, b);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
386
src/main/java/malte0811/industrialWires/client/ClientProxy.java
Normal file
386
src/main/java/malte0811/industrialWires/client/ClientProxy.java
Normal file
|
@ -0,0 +1,386 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialWires.client;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ManualHelper;
|
||||
import blusunrize.immersiveengineering.api.ManualPageMultiblock;
|
||||
import blusunrize.immersiveengineering.client.ClientUtils;
|
||||
import blusunrize.immersiveengineering.client.models.smart.ConnLoader;
|
||||
import blusunrize.immersiveengineering.common.Config;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import blusunrize.lib.manual.ManualInstance;
|
||||
import blusunrize.lib.manual.ManualPages;
|
||||
import blusunrize.lib.manual.ManualPages.PositionedItemStack;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import malte0811.industrialWires.CommonProxy;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IWPotions;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelComponent;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.client.gui.GuiRSPanelConn;
|
||||
import malte0811.industrialWires.client.gui.GuiRenameKey;
|
||||
import malte0811.industrialWires.client.manual.TextSplitter;
|
||||
import malte0811.industrialWires.client.panelmodel.PanelModelLoader;
|
||||
import malte0811.industrialWires.client.render.Shaders;
|
||||
import malte0811.industrialWires.client.render.TileRenderJacobsLadder;
|
||||
import malte0811.industrialWires.client.render.TileRenderMarx;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.crafting.IC2TRHelper;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import malte0811.industrialWires.hv.MultiblockMarx;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.MovingSound;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
public void preInit() {
|
||||
super.preInit();
|
||||
if (IndustrialWires.hasIC2) {
|
||||
ConnLoader.baseModels.put("ic2_conn_tin", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_tin", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_tin"));
|
||||
ConnLoader.baseModels.put("ic2_relay_tin", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_tin", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_relay_tin"));
|
||||
|
||||
ConnLoader.baseModels.put("ic2_conn_copper", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_copper", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_copper"));
|
||||
ConnLoader.baseModels.put("ic2_relay_copper", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_copper", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_relay_copper"));
|
||||
|
||||
ConnLoader.baseModels.put("ic2_conn_gold", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_gold", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_gold"));
|
||||
ConnLoader.baseModels.put("ic2_relay_gold", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_gold", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_relay_gold"));
|
||||
|
||||
ConnLoader.baseModels.put("ic2_conn_hv", new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_hv", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_hv"));
|
||||
ConnLoader.baseModels.put("ic2_relay_hv", new ResourceLocation("immersiveengineering:block/connector/relay_hv.obj"));
|
||||
|
||||
ConnLoader.baseModels.put("ic2_conn_glass", new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_glass", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_glass"));
|
||||
ConnLoader.baseModels.put("ic2_relay_glass", new ResourceLocation("immersiveengineering:block/connector/relay_hv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_glass", ImmutableMap.of("#immersiveengineering:blocks/connector_relay_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_relay_glass"));
|
||||
}
|
||||
ConnLoader.baseModels.put("rs_panel_conn", new ResourceLocation("industrialwires:block/rs_panel_conn.obj"));
|
||||
|
||||
ConnLoader.baseModels.put("empty", new ResourceLocation("builtin/generated"));
|
||||
|
||||
OBJLoader.INSTANCE.addDomain(IndustrialWires.MODID);
|
||||
ModelLoaderRegistry.registerLoader(new PanelModelLoader());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJacobsLadder.class, new TileRenderJacobsLadder());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMarx.class, new TileRenderMarx());
|
||||
Shaders.initShaders(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
super.postInit();
|
||||
ManualInstance m = ManualHelper.getManual();
|
||||
if (IndustrialWires.hasIC2) {
|
||||
PositionedItemStack[][] wireRecipes = new PositionedItemStack[3][10];
|
||||
int xBase = 15;
|
||||
Ingredient tinCable = IC2TRHelper.getStack("cable", "type:tin,insulation:0");
|
||||
List<ItemStack> tinCableList = Arrays.asList(tinCable.getMatchingStacks());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
wireRecipes[0][3 * i + j] = new PositionedItemStack(tinCableList, 18 * i + xBase, 18 * j);
|
||||
}
|
||||
}
|
||||
ItemStack tmp = new ItemStack(IndustrialWires.coil);
|
||||
ItemIC2Coil.setLength(tmp, 9);
|
||||
wireRecipes[0][9] = new PositionedItemStack(tmp, 18 * 4 + xBase, 18);
|
||||
Random r = new Random();
|
||||
for (int i = 1; i < 3; i++) {
|
||||
int lengthSum = 0;
|
||||
for (int j1 = 0; j1 < 3; j1++) {
|
||||
for (int j2 = 0; j2 < 3; j2++) {
|
||||
if (r.nextBoolean()) {
|
||||
// cable
|
||||
lengthSum++;
|
||||
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(tinCableList, 18 * j1 + xBase, 18 * j2);
|
||||
} else {
|
||||
// wire coil
|
||||
int length = r.nextInt(99) + 1;
|
||||
tmp = new ItemStack(IndustrialWires.coil);
|
||||
ItemIC2Coil.setLength(tmp, length);
|
||||
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(tmp, 18 * j1 + xBase, 18 * j2);
|
||||
lengthSum += length;
|
||||
}
|
||||
}
|
||||
}
|
||||
tmp = new ItemStack(IndustrialWires.coil);
|
||||
ItemIC2Coil.setLength(tmp, lengthSum);
|
||||
wireRecipes[i][9] = new PositionedItemStack(tmp, 18 * 4 + xBase, 18);
|
||||
}
|
||||
|
||||
m.addEntry("industrialwires.wires", "industrialwires",
|
||||
new ManualPages.CraftingMulti(m, "industrialwires.wires0", new ItemStack(IndustrialWires.ic2conn, 1, 0), new ItemStack(IndustrialWires.ic2conn, 1, 1), new ItemStack(IndustrialWires.ic2conn, 1, 2), new ItemStack(IndustrialWires.ic2conn, 1, 3),
|
||||
new ItemStack(IndustrialWires.ic2conn, 1, 4), new ItemStack(IndustrialWires.ic2conn, 1, 5), new ItemStack(IndustrialWires.ic2conn, 1, 6), new ItemStack(IndustrialWires.ic2conn, 1, 7)),
|
||||
new ManualPages.Text(m, "industrialwires.wires1"),
|
||||
new ManualPages.CraftingMulti(m, "industrialwires.wires2", (Object[]) wireRecipes)
|
||||
);
|
||||
if (IndustrialWires.mechConv != null) {
|
||||
m.addEntry("industrialwires.mechConv", "industrialwires",
|
||||
new ManualPages.Crafting(m, "industrialwires.mechConv0", new ItemStack(IndustrialWires.mechConv, 1, 1)),
|
||||
new ManualPages.Crafting(m, "industrialwires.mechConv1", new ItemStack(IndustrialWires.mechConv, 1, 2)),
|
||||
new ManualPages.Crafting(m, "industrialwires.mechConv2", new ItemStack(IndustrialWires.mechConv, 1, 0))
|
||||
);
|
||||
}
|
||||
}
|
||||
int oldLength = Config.IEConfig.Tools.earDefenders_SoundBlacklist.length;
|
||||
Config.IEConfig.Tools.earDefenders_SoundBlacklist =
|
||||
Arrays.copyOf(Config.IEConfig.Tools.earDefenders_SoundBlacklist, oldLength + 1);
|
||||
Config.IEConfig.Tools.earDefenders_SoundBlacklist[oldLength] = TINNITUS_LOC.toString();
|
||||
|
||||
ClientUtils.mc().getItemColors().registerItemColorHandler((stack, pass) -> {
|
||||
if (pass == 1) {
|
||||
PanelComponent pc = ItemPanelComponent.componentFromStack(stack);
|
||||
if (pc != null) {
|
||||
return 0xff000000 | pc.getColor();
|
||||
}
|
||||
}
|
||||
return ~0;
|
||||
}, IndustrialWires.panelComponent);
|
||||
|
||||
Config.manual_doubleA.put("iwJacobsUsage", IWConfig.HVStuff.jacobsUsageEU);
|
||||
Config.manual_int.put("iwKeysOnRing", IWConfig.maxKeysOnRing);
|
||||
m.addEntry("industrialwires.jacobs", IndustrialWires.MODID,
|
||||
new ManualPages.CraftingMulti(m, "industrialwires.jacobs0", new ItemStack(IndustrialWires.jacobsLadder, 1, 0), new ItemStack(IndustrialWires.jacobsLadder, 1, 1), new ItemStack(IndustrialWires.jacobsLadder, 1, 2)),
|
||||
new ManualPages.Text(m, "industrialwires.jacobs1"));
|
||||
|
||||
|
||||
m.addEntry("industrialwires.intro", "control_panels",
|
||||
new ManualPages.Text(m, "industrialwires.intro0"),
|
||||
new ManualPages.Text(m, "industrialwires.intro1"),
|
||||
new ManualPages.Crafting(m, "industrialwires.intro2", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.DUMMY.ordinal())),
|
||||
new ManualPages.Text(m, "industrialwires.intro3"),
|
||||
new ManualPages.Crafting(m, "industrialwires.intro4", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.UNFINISHED.ordinal())),
|
||||
new ManualPages.Text(m, "industrialwires.intro5")
|
||||
);
|
||||
m.addEntry("industrialwires.panel_creator", "control_panels",
|
||||
new ManualPages.Crafting(m, "industrialwires.panel_creator0", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.CREATOR.ordinal())),
|
||||
new ManualPages.Text(m, "industrialwires.panel_creator1"),
|
||||
new ManualPages.Text(m, "industrialwires.panel_creator2")
|
||||
);
|
||||
m.addEntry("industrialwires.redstone", "control_panels",
|
||||
new ManualPages.Crafting(m, "industrialwires.redstone0", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.RS_WIRE.ordinal())),
|
||||
new ManualPages.Text(m, "industrialwires.redstone1")
|
||||
);
|
||||
m.addEntry("industrialwires.components", "control_panels",
|
||||
new ManualPages.Text(m, "industrialwires.components.general"),
|
||||
new ManualPages.Crafting(m, "industrialwires.button", new ItemStack(IndustrialWires.panelComponent, 1, 0)),
|
||||
new ManualPages.Crafting(m, "industrialwires.label", new ItemStack(IndustrialWires.panelComponent, 1, 1)),
|
||||
new ManualPages.Crafting(m, "industrialwires.indicator_light", new ItemStack(IndustrialWires.panelComponent, 1, 2)),
|
||||
new ManualPages.Crafting(m, "industrialwires.slider", new ItemStack(IndustrialWires.panelComponent, 1, 3)),
|
||||
new ManualPages.CraftingMulti(m, "industrialwires.toggle_switch", new ItemStack(IndustrialWires.panelComponent, 1, 5), new ItemStack(IndustrialWires.panelComponent, 1, 6)),
|
||||
new ManualPages.Text(m, "industrialwires.toggle_switch1"),
|
||||
new ManualPages.Crafting(m, "industrialwires.variac", new ItemStack(IndustrialWires.panelComponent, 1, 4)),
|
||||
new ManualPages.CraftingMulti(m, "industrialwires.lock", new ItemStack(IndustrialWires.panelComponent, 1, 7), new ItemStack(IndustrialWires.key)),
|
||||
new ManualPages.Crafting(m, "industrialwires.lock1", new ItemStack(IndustrialWires.key, 1, 2)),
|
||||
new ManualPages.Crafting(m, "industrialwires.panel_meter", new ItemStack(IndustrialWires.panelComponent, 1, 8)),
|
||||
new ManualPages.Crafting(m, "industrialwires.7seg", new ItemStack(IndustrialWires.panelComponent, 1, 9))
|
||||
);
|
||||
List<MarxOreHandler.OreInfo> ores = MarxOreHandler.getRecipes();
|
||||
String text = I18n.format("ie.manual.entry.industrialwires.marx");
|
||||
for (int i = 0; i < ores.size(); i++) {
|
||||
MarxOreHandler.OreInfo curr = ores.get(i);
|
||||
if (!curr.exampleInput.isEmpty()) {
|
||||
text += I18n.format(IndustrialWires.MODID + ".desc.input") + ": §l" + curr.exampleInput.get(0).getDisplayName() + "§r<br>";
|
||||
text += I18n.format(IndustrialWires.MODID + ".desc.output") + ": " + Utils.formatDouble(curr.maxYield, "0.#") + "x" + curr.output.get().getDisplayName() + "<br>";
|
||||
if (curr.outputSmall != null && !curr.outputSmall.get().isEmpty()) {
|
||||
text += I18n.format(IndustrialWires.MODID + ".desc.alt") + ": " + curr.smallMax + "x" + curr.outputSmall.get().getDisplayName() + "<br>";
|
||||
}
|
||||
text += I18n.format(IndustrialWires.MODID + ".desc.ideal_e") + ": " + Utils.formatDouble(curr.avgEnergy * MarxOreHandler.defaultEnergy / 1000, "0.#") + " kJ<br><br>";
|
||||
}
|
||||
}
|
||||
boolean uni = m.fontRenderer.getUnicodeFlag();
|
||||
m.fontRenderer.setUnicodeFlag(true);
|
||||
m.entryRenderPre();
|
||||
TextSplitter splitter = new TextSplitter(m.fontRenderer::getStringWidth, 16, 120,
|
||||
(s) -> new ManualPages.Text(m, s));
|
||||
splitter.addSpecialPage(0, 0, 6,
|
||||
(s) -> new ManualPageMultiblock(m, s,
|
||||
MultiblockMarx.INSTANCE));
|
||||
splitter.split(text);
|
||||
m.entryRenderPost();
|
||||
m.fontRenderer.setUnicodeFlag(uni);
|
||||
List<ManualPages> marxEntry = splitter.toManualEntry();
|
||||
m.addEntry("industrialwires.marx", IndustrialWires.MODID, marxEntry.toArray(new ManualPages[marxEntry.size()]));
|
||||
}
|
||||
|
||||
private static final ResourceLocation TINNITUS_LOC = new ResourceLocation(IndustrialWires.MODID, "tinnitus");
|
||||
private static ISound playingTinnitus = null;
|
||||
@Override
|
||||
public void startTinnitus() {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (playingTinnitus==null||!mc.getSoundHandler().isSoundPlaying(playingTinnitus)) {
|
||||
playingTinnitus = getTinnitus();
|
||||
mc.getSoundHandler().playSound(playingTinnitus);
|
||||
}
|
||||
}
|
||||
|
||||
private ISound getTinnitus() {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
return new MovingSound(new SoundEvent(TINNITUS_LOC), SoundCategory.PLAYERS) {
|
||||
@Override
|
||||
public void update() {
|
||||
if (mc.player.getActivePotionEffect(IWPotions.tinnitus)==null) {
|
||||
donePlaying = true;
|
||||
playingTinnitus = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVolume() {
|
||||
return .5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXPosF() {
|
||||
return (float) mc.player.posX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getYPosF() {
|
||||
return (float) mc.player.posY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZPosF() {
|
||||
return (float) mc.player.posZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRepeat() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getClientWorld() {
|
||||
return Minecraft.getMinecraft().world;
|
||||
}
|
||||
|
||||
private WeakHashMap<BlockPos, ISound> playingSounds = new WeakHashMap<>();
|
||||
private static ResourceLocation jacobsStart = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_start");//~470 ms ~=9 ticks
|
||||
private static ResourceLocation jacobsMiddle = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_middle");
|
||||
private static ResourceLocation jacobsEnd = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_end");//~210 ms ~= 4 ticks
|
||||
private static ResourceLocation marxBang = new ResourceLocation(IndustrialWires.MODID, "marx_bang");
|
||||
private static ResourceLocation marxPop = new ResourceLocation(IndustrialWires.MODID, "marx_pop");
|
||||
|
||||
@Override
|
||||
public void playJacobsLadderSound(TileEntityJacobsLadder te, int phase, Vec3d soundPos) {
|
||||
if (playingSounds.containsKey(te.getPos())) {
|
||||
Minecraft.getMinecraft().getSoundHandler().stopSound(playingSounds.get(te.getPos()));
|
||||
playingSounds.remove(te.getPos());
|
||||
}
|
||||
ResourceLocation event;
|
||||
switch (phase) {
|
||||
case 0:
|
||||
event = jacobsStart;
|
||||
break;
|
||||
case 1:
|
||||
event = jacobsMiddle;
|
||||
break;
|
||||
case 2:
|
||||
event = jacobsEnd;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
PositionedSoundRecord sound = new PositionedSoundRecord(event, SoundCategory.BLOCKS, te.size.soundVolume, 1, false, 0, ISound.AttenuationType.LINEAR, (float) soundPos.x, (float) soundPos.y, (float) soundPos.z);
|
||||
ClientUtils.mc().getSoundHandler().playSound(sound);
|
||||
playingSounds.put(te.getPos(), sound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMarxBang(TileEntityMarx te, Vec3d pos, float energy) {
|
||||
ResourceLocation soundLoc = marxBang;
|
||||
if (energy<0) {
|
||||
energy = -energy;
|
||||
soundLoc = marxPop;
|
||||
}
|
||||
PositionedSoundRecord sound = new PositionedSoundRecord(soundLoc, SoundCategory.BLOCKS, 5*energy, 1, false, 0, ISound.AttenuationType.LINEAR, (float) pos.x, (float) pos.y, (float) pos.z);
|
||||
ClientUtils.mc().getSoundHandler().playSound(sound);
|
||||
playingSounds.put(te.getPos(), sound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gui getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID == 0) {
|
||||
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
return new GuiRSPanelConn((TileEntityRSPanelConn) te);
|
||||
}
|
||||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new GuiPanelCreator(player.inventory, (TileEntityPanelCreator) te);
|
||||
}
|
||||
} else if (ID == 1) {
|
||||
EnumHand h = z == 1 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
|
||||
ItemStack held = player.getHeldItem(h);
|
||||
if (!held.isEmpty()) {
|
||||
if (held.getItem() == IndustrialWires.panelComponent) {
|
||||
return new GuiPanelComponent(h, ItemPanelComponent.componentFromStack(held));
|
||||
} else if (held.getItem() == IndustrialWires.key) {
|
||||
return new GuiRenameKey(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package malte0811.industrialWires.client;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ClientUtilsIW {
|
||||
/**
|
||||
* Base on {@link blusunrize.immersiveengineering.client.ClientUtils#renderModelTESRFast(List, BufferBuilder, World, BlockPos)}
|
||||
* (which I wrote)
|
||||
*/
|
||||
public static void renderModelTESRFast(List<BakedQuad> quads, BufferBuilder renderer) {
|
||||
int brightness = 15 << 20 | 15 << 4;
|
||||
int l1 = (brightness >> 0x10) & 0xFFFF;
|
||||
int l2 = brightness & 0xFFFF;
|
||||
for (BakedQuad quad : quads) {
|
||||
int[] vData = quad.getVertexData();
|
||||
VertexFormat format = quad.getFormat();
|
||||
int size = format.getIntegerSize();
|
||||
int uv = format.getUvOffsetById(0) / 4;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
renderer
|
||||
.pos(Float.intBitsToFloat(vData[size * i]),
|
||||
Float.intBitsToFloat(vData[size * i + 1]),
|
||||
Float.intBitsToFloat(vData[size * i + 2]))
|
||||
.color(255, 255, 255, 255)
|
||||
.tex(Float.intBitsToFloat(vData[size * i + uv]), Float.intBitsToFloat(vData[size * i + uv + 1]))
|
||||
.lightmap(l1, l2)
|
||||
.endVertex();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +1,26 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client;
|
||||
package malte0811.industrialWires.client;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -31,7 +29,6 @@ import java.util.Arrays;
|
|||
import static org.lwjgl.util.vector.Vector3f.cross;
|
||||
import static org.lwjgl.util.vector.Vector3f.sub;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RawQuad {
|
||||
public final Vector3f[] vertices = new Vector3f[4];
|
||||
public final EnumFacing facing;
|
||||
|
@ -81,56 +78,10 @@ public class RawQuad {
|
|||
this.light = light;
|
||||
}
|
||||
|
||||
public static RawQuad unbake(BakedQuad q) {
|
||||
Vector3f[] vertices = new Vector3f[4];
|
||||
float[] color = new float[4];
|
||||
Vector3f normal = new Vector3f();
|
||||
float[][] uvs = new float[4][2];
|
||||
TextureAtlasSprite sprite = q.getSprite();
|
||||
VertexFormat format = q.getFormat();
|
||||
int pos = 0;
|
||||
for (int v = 0; v < 4; v++) {
|
||||
for (int e = 0; e < format.getElementCount(); e++) {
|
||||
switch (format.getElement(e).getUsage()) {
|
||||
case POSITION:
|
||||
int x = q.getVertexData()[pos];
|
||||
int y = q.getVertexData()[pos + 1];
|
||||
int z = q.getVertexData()[pos + 2];
|
||||
vertices[v] = new Vector3f(Float.intBitsToFloat(x),
|
||||
Float.intBitsToFloat(y),
|
||||
Float.intBitsToFloat(z));
|
||||
break;
|
||||
case COLOR:
|
||||
for (int i = 0; i < 4; i++) {
|
||||
color[i] = Float.intBitsToFloat(q.getVertexData()[pos + i]);
|
||||
}
|
||||
break;
|
||||
case UV:
|
||||
if (format.getElement(e).getType() == VertexFormatElement.EnumType.FLOAT) {
|
||||
uvs[v][0] = sprite.getUnInterpolatedU(Float.intBitsToFloat(q.getVertexData()[pos]));
|
||||
uvs[v][1] = sprite.getUnInterpolatedV(Float.intBitsToFloat(q.getVertexData()[pos + 1]));
|
||||
}
|
||||
break;
|
||||
case NORMAL:
|
||||
x = q.getVertexData()[pos];
|
||||
y = q.getVertexData()[pos + 1];
|
||||
z = q.getVertexData()[pos + 2];
|
||||
normal.set(Float.intBitsToFloat(x),
|
||||
Float.intBitsToFloat(y),
|
||||
Float.intBitsToFloat(z));
|
||||
break;
|
||||
}
|
||||
pos += format.getElement(e).getSize() / 4;
|
||||
}
|
||||
}
|
||||
return new RawQuad(vertices[0], vertices[1], vertices[2], vertices[3],
|
||||
q.getFace(), sprite, color, normal, uvs, -1);
|
||||
}
|
||||
|
||||
public RawQuad apply(Matrix4 mat) {
|
||||
Matrix4 matNormal = mat.copy().transpose();
|
||||
matNormal.invert();
|
||||
return new RawQuad(mat.apply(vertices[0]), mat.apply(vertices[1]), mat.apply(vertices[2]), mat.apply(vertices[3]),
|
||||
facing, tex, colorA, matNormal.apply(normal), uvs, light);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,32 +1,18 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.gui;
|
||||
package malte0811.industrialWires.client.gui;
|
||||
|
||||
import blusunrize.immersiveengineering.client.ClientUtils;
|
||||
import blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox;
|
||||
import blusunrize.immersiveengineering.client.gui.elements.GuiSliderIE;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.gui.elements.GuiChannelPicker;
|
||||
import malte0811.industrialwires.client.gui.elements.GuiChannelPickerSmall;
|
||||
import malte0811.industrialwires.client.gui.elements.GuiIntChooser;
|
||||
import malte0811.industrialwires.containers.ContainerPanelComponent;
|
||||
import malte0811.industrialwires.controlpanel.IConfigurableComponent;
|
||||
import malte0811.industrialwires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialwires.network.MessageItemSync;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.client.gui.elements.GuiChannelPicker;
|
||||
import malte0811.industrialWires.client.gui.elements.GuiChannelPickerSmall;
|
||||
import malte0811.industrialWires.client.gui.elements.GuiIntChooser;
|
||||
import malte0811.industrialWires.containers.ContainerPanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.IConfigurableComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.network.MessageItemSync;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
@ -43,8 +29,6 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
|
||||
public class GuiPanelComponent extends GuiContainer {
|
||||
private PanelComponent component;
|
||||
private IConfigurableComponent confComp;
|
||||
|
@ -84,9 +68,9 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
toAdd.setText(sc.value);
|
||||
stringTexts.add(toAdd);
|
||||
}
|
||||
IConfigurableComponent.RSColorConfig[] rs = confComp.getRSChannelOptions();
|
||||
IConfigurableComponent.RSChannelConfig[] rs = confComp.getRSChannelOptions();
|
||||
rsChannelChoosers.clear();
|
||||
for (IConfigurableComponent.RSColorConfig rc : rs) {
|
||||
for (IConfigurableComponent.RSChannelConfig rc : rs) {
|
||||
if (rc.small) {
|
||||
rsChannelChoosers.add(new GuiChannelPickerSmall(0, componentLeft + rc.x, componentTop + rc.y, 10, 40, rc.value));
|
||||
} else {
|
||||
|
@ -288,41 +272,41 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
|
||||
private void sync(int id, String value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setString(VALUE, value);
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setString(ItemPanelComponent.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, boolean value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setBoolean(VALUE, value);
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setBoolean(ItemPanelComponent.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, byte value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setByte(VALUE, value);
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setByte(ItemPanelComponent.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, int value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setInteger(VALUE, value);
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setInteger(ItemPanelComponent.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, float value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setFloat(VALUE, value);
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setFloat(ItemPanelComponent.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
|
@ -330,37 +314,37 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
NBTTagList list = new NBTTagList();
|
||||
for (int i = 0; i < stringTexts.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setString(VALUE, stringTexts.get(i).getText());
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setString(ItemPanelComponent.VALUE, stringTexts.get(i).getText());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0; i < boolButtons.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setBoolean(VALUE, boolButtons.get(i).state);
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setBoolean(ItemPanelComponent.VALUE, boolButtons.get(i).state);
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0; i < rsChannelChoosers.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setByte(VALUE, rsChannelChoosers.get(i).getSelected());
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setByte(ItemPanelComponent.VALUE, rsChannelChoosers.get(i).getSelected());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0; i < intChoosers.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setInteger(VALUE, intChoosers.get(i).getValue());
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setInteger(ItemPanelComponent.VALUE, intChoosers.get(i).getValue());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0; i < floatSliders.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setFloat(VALUE, (float) floatSliders.get(i).getValue());
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setFloat(ItemPanelComponent.VALUE, (float) floatSliders.get(i).getValue());
|
||||
list.appendTag(update);
|
||||
}
|
||||
sync(list);
|
|
@ -1,30 +1,33 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.gui;
|
||||
package malte0811.industrialWires.client.gui;
|
||||
|
||||
import blusunrize.immersiveengineering.client.ClientUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialwires.containers.ContainerPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.MessageType;
|
||||
import malte0811.industrialwires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialwires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialwires.items.ItemPanelComponent;
|
||||
import malte0811.industrialwires.network.MessageGUIInteract;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.containers.ContainerPanelCreator;
|
||||
import malte0811.industrialWires.controlpanel.MessageType;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.network.MessageGUIInteract;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
@ -36,10 +39,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.ImmutableTriple;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.apache.commons.lang3.tuple.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -309,7 +309,7 @@ public class GuiPanelCreator extends GuiContainer {
|
|||
nbt.setInteger("type", MessageType.DISASSEMBLE.ordinal());
|
||||
break;
|
||||
}
|
||||
if (!nbt.isEmpty()) {
|
||||
if (!nbt.hasNoTags()) {
|
||||
IndustrialWires.packetHandler.sendToServer(new MessageGUIInteract(container.tile, nbt));
|
||||
}
|
||||
}
|
|
@ -1,25 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.gui;
|
||||
package malte0811.industrialWires.client.gui;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityRSPanel;
|
||||
import malte0811.industrialwires.client.gui.elements.GuiIntChooser;
|
||||
import malte0811.industrialwires.containers.ContainerRSPanelConn;
|
||||
import malte0811.industrialwires.network.MessageGUIInteract;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.client.gui.elements.GuiIntChooser;
|
||||
import malte0811.industrialWires.containers.ContainerRSPanelConn;
|
||||
import malte0811.industrialWires.network.MessageGUIInteract;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -30,10 +33,10 @@ import net.minecraft.util.ResourceLocation;
|
|||
import java.io.IOException;
|
||||
|
||||
public class GuiRSPanelConn extends GuiContainer {
|
||||
private TileEntityRSPanel te;
|
||||
private TileEntityRSPanelConn te;
|
||||
private GuiIntChooser chooser;
|
||||
|
||||
public GuiRSPanelConn(TileEntityRSPanel tile) {
|
||||
public GuiRSPanelConn(TileEntityRSPanelConn tile) {
|
||||
super(new ContainerRSPanelConn(tile));
|
||||
te = tile;
|
||||
}
|
|
@ -1,23 +1,26 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.gui;
|
||||
package malte0811.industrialWires.client.gui;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.containers.ContainerRenameKey;
|
||||
import malte0811.industrialwires.network.MessageItemSync;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.containers.ContainerRenameKey;
|
||||
import malte0811.industrialWires.network.MessageItemSync;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
@ -1,19 +1,4 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.gui.elements;
|
||||
package malte0811.industrialWires.client.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.gui.elements;
|
||||
package malte0811.industrialWires.client.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
|
@ -1,19 +1,4 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.gui.elements;
|
||||
package malte0811.industrialWires.client.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialWires.client.manual;
|
||||
|
||||
import blusunrize.lib.manual.ManualPages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TextSplitter {
|
||||
private final Function<String, Integer> width;
|
||||
private final int lineWidth;
|
||||
private Map<Integer, Map<Integer, Page>> linesOnSpecialPages = new HashMap<>();
|
||||
private Map<Integer, Page> pageToSpecial = new HashMap<>();
|
||||
private List<List<String>> entry = new ArrayList<>();
|
||||
private Page defPage;
|
||||
public TextSplitter(Function<String, Integer> w, int lP, int lW, Function<String, ManualPages> defaultPage) {
|
||||
width = w;
|
||||
lineWidth = lW;
|
||||
defPage = new Page(lP, defaultPage);
|
||||
}
|
||||
|
||||
public void clearSpecial() {
|
||||
linesOnSpecialPages.clear();
|
||||
}
|
||||
|
||||
public void addSpecialPage(int ref, int offset, int linesOnPage, Function<String, ManualPages> factory) {
|
||||
if (offset<0||(ref!=-1&&ref<0)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (!linesOnSpecialPages.containsKey(ref)) {
|
||||
linesOnSpecialPages.put(ref, new HashMap<>());
|
||||
}
|
||||
linesOnSpecialPages.get(ref).put(offset, new Page(linesOnPage, factory));
|
||||
}
|
||||
|
||||
// I added labels to all break statements to make it more readable
|
||||
@SuppressWarnings({"UnnecessaryLabelOnBreakStatement", "UnusedLabel"})
|
||||
public void split(String in) {
|
||||
String[] wordsAndSpaces = splitWhitespace(in);
|
||||
int pos = 0;
|
||||
List<String> overflow = new ArrayList<>();
|
||||
updateSpecials(-1, 0);
|
||||
entry:while (pos<wordsAndSpaces.length) {
|
||||
List<String> page = new ArrayList<>();
|
||||
page.addAll(overflow);
|
||||
overflow.clear();
|
||||
page:while (page.size()<getLinesOnPage(entry.size())&&pos<wordsAndSpaces.length) {
|
||||
String line = "";
|
||||
int currWidth = 0;
|
||||
line:while (pos<wordsAndSpaces.length&&currWidth<lineWidth) {
|
||||
String text = wordsAndSpaces[pos];
|
||||
if (pos<wordsAndSpaces.length) {
|
||||
int textWidth = getWidth(text);
|
||||
if (currWidth + textWidth < lineWidth||line.length()==0) {
|
||||
pos++;
|
||||
if (text.equals("<np>")) {
|
||||
page.add(line);
|
||||
break page;
|
||||
} else if (text.equals("<br>")) {
|
||||
break line;
|
||||
} else if (text.startsWith("<&")&&text.endsWith(">")) {
|
||||
int id = Integer.parseInt(text.substring(2, text.length()-1));
|
||||
int pageForId = entry.size();
|
||||
Map<Integer, Page> specialForId = linesOnSpecialPages.get(id);
|
||||
if (specialForId!=null&&specialForId.containsKey(0)) {
|
||||
if (page.size()>getLinesOnPage(pageForId)) {
|
||||
pageForId++;
|
||||
}
|
||||
}
|
||||
updateSpecials(id, pageForId);
|
||||
} else if (!Character.isWhitespace(text.charAt(0))||line.length()!=0) {//Don't add whitespace at the start of a line
|
||||
line += text;
|
||||
currWidth += textWidth;
|
||||
}
|
||||
} else {
|
||||
break line;
|
||||
}
|
||||
}
|
||||
}
|
||||
page.add(line);
|
||||
}
|
||||
if (!page.stream().allMatch(String::isEmpty)) {
|
||||
int linesMax = getLinesOnPage(entry.size());
|
||||
if (page.size()>linesMax) {
|
||||
overflow.addAll(page.subList(linesMax, page.size()));
|
||||
page = page.subList(0, linesMax-1);
|
||||
}
|
||||
entry.add(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ManualPages> toManualEntry() {
|
||||
List<ManualPages> ret = new ArrayList<>(entry.size());
|
||||
for (int i = 0; i < entry.size(); i++) {
|
||||
String s = entry.get(i).stream().collect(Collectors.joining("\n"));
|
||||
ret.add(pageToSpecial.getOrDefault(i, defPage).factory.apply(s));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getWidth(String text) {
|
||||
switch (text) {
|
||||
case "<br>":
|
||||
case "<np>":
|
||||
return 0;
|
||||
default:
|
||||
if (text.startsWith("<link;")) {
|
||||
text = text.substring(text.indexOf(';') + 1);
|
||||
text = text.substring(text.indexOf(';') + 1, text.lastIndexOf(';'));
|
||||
}
|
||||
return width.apply(text);
|
||||
}
|
||||
}
|
||||
|
||||
private int getLinesOnPage(int id) {
|
||||
if (pageToSpecial.containsKey(id)) {
|
||||
return pageToSpecial.get(id).lines;
|
||||
}
|
||||
return defPage.lines;
|
||||
}
|
||||
|
||||
private void updateSpecials(int ref, int page) {
|
||||
if (linesOnSpecialPages.containsKey(ref)) {
|
||||
for (Map.Entry<Integer, Page> entry :linesOnSpecialPages.get(ref).entrySet()) {
|
||||
int specialPage = page+entry.getKey();
|
||||
if (pageToSpecial.containsKey(specialPage)) {
|
||||
throw new IllegalStateException("Page "+specialPage+" was registered already");
|
||||
}
|
||||
pageToSpecial.put(specialPage, entry.getValue());
|
||||
}
|
||||
} else if (ref!=-1) {//Default reference for page 0
|
||||
System.out.println("WARNING: Reference "+ref+" was found, but no special pages were registered for it");
|
||||
}
|
||||
}
|
||||
|
||||
private String[] splitWhitespace(String in) {
|
||||
List<String> parts = new ArrayList<>();
|
||||
for (int i = 0;i<in.length();) {
|
||||
StringBuilder here = new StringBuilder();
|
||||
char first = in.charAt(i);
|
||||
here.append(first);
|
||||
i++;
|
||||
for (;i<in.length();) {
|
||||
char hereC = in.charAt(i);
|
||||
byte action = shouldSplit(first, hereC);
|
||||
if ((action&1)!=0) {
|
||||
here.append(in.charAt(i));
|
||||
i++;
|
||||
}
|
||||
if ((action&2)!=0||(action&1)==0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
parts.add(here.toString());
|
||||
}
|
||||
return parts.toArray(new String[parts.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* &1: add
|
||||
* &2: end here
|
||||
*/
|
||||
private byte shouldSplit(char start, char here) {
|
||||
byte ret = 0b01;
|
||||
if (Character.isWhitespace(start)^Character.isWhitespace(here)) {
|
||||
ret = 0b10;
|
||||
}
|
||||
if (here=='<') {
|
||||
ret = 0b10;
|
||||
}
|
||||
if (start=='<') {
|
||||
ret = 0b01;
|
||||
if (here=='>') {
|
||||
ret |= 0b10;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<List<String>> getEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
private class Page {
|
||||
final int lines;
|
||||
final Function<String, ManualPages> factory;
|
||||
public Page(int l, Function<String, ManualPages> f) {
|
||||
factory = f;
|
||||
lines = l;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,30 +1,33 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.panelmodel;
|
||||
package malte0811.industrialWires.client.panelmodel;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEApi;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import malte0811.industrialwires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityUnfinishedPanel;
|
||||
import malte0811.industrialwires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialwires.controlpanel.PropertyComponents;
|
||||
import malte0811.industrialwires.controlpanel.PropertyComponents.PanelRenderProperties;
|
||||
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityUnfinishedPanel;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents.PanelRenderProperties;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
@ -33,8 +36,6 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -44,7 +45,6 @@ import java.util.List;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PanelModel implements IBakedModel {
|
||||
public final static Cache<PanelRenderProperties, AssembledBakedModel> modelCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(100)
|
|
@ -1,23 +1,26 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.panelmodel;
|
||||
package malte0811.industrialWires.client.panelmodel;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
|
@ -47,13 +50,13 @@ public class PanelModelLoader implements ICustomModelLoader {
|
|||
|
||||
@Override
|
||||
public boolean accepts(@Nonnull ResourceLocation modelLocation) {
|
||||
return modelLocation.getPath().contains(RESOURCE_BASE + RESOURCE_LOCATION);
|
||||
return modelLocation.getResourcePath().contains(RESOURCE_BASE + RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModel loadModel(@Nonnull ResourceLocation modelLocation) throws IOException {
|
||||
String resourcePath = modelLocation.getPath();
|
||||
String resourcePath = modelLocation.getResourcePath();
|
||||
int pos = resourcePath.indexOf(RESOURCE_LOCATION);
|
||||
if (pos >= 0) {
|
||||
return new PanelModelBase();
|
|
@ -1,23 +1,26 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.panelmodel;
|
||||
package malte0811.industrialWires.client.panelmodel;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
@ -91,10 +94,10 @@ public class RawModelFontRenderer extends FontRenderer {
|
|||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
super.onResourceManagerReload(resourceManager);
|
||||
String p = locationFontTexture.getPath();
|
||||
String p = locationFontTexture.getResourcePath();
|
||||
if (p.startsWith("textures/")) p = p.substring("textures/".length(), p.length());
|
||||
if (p.endsWith(".png")) p = p.substring(0, p.length() - ".png".length());
|
||||
String f = locationFontTexture.getNamespace() + ":" + p;
|
||||
String f = locationFontTexture.getResourceDomain() + ":" + p;
|
||||
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(f);
|
||||
}
|
||||
|
|
@ -1,19 +1,4 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.panelmodel;
|
||||
package malte0811.industrialWires.client.panelmodel;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
|
@ -13,11 +13,11 @@
|
|||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.render;
|
||||
package malte0811.industrialWires.client.render;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEApi;
|
||||
import malte0811.industrialwires.IWConfig;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.opengl.ARBFragmentShader;
|
|
@ -1,23 +1,26 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.render;
|
||||
package malte0811.industrialWires.client.render;
|
||||
|
||||
import malte0811.industrialwires.blocks.hv.TileEntityJacobsLadder;
|
||||
import malte0811.industrialwires.blocks.hv.TileEntityJacobsLadder.LadderSize;
|
||||
import malte0811.industrialwires.util.Beziers;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder.LadderSize;
|
||||
import malte0811.industrialWires.util.Beziers;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
@ -26,7 +29,7 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static malte0811.industrialwires.blocks.hv.TileEntityJacobsLadder.getColor;
|
||||
import static malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder.getColor;
|
||||
|
||||
public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntityJacobsLadder> {
|
||||
@Override
|
|
@ -1,26 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.client.render;
|
||||
package malte0811.industrialWires.client.render;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.blocks.IWProperties;
|
||||
import malte0811.industrialwires.blocks.hv.TileEntityMarx;
|
||||
import malte0811.industrialwires.blocks.hv.TileEntityMarx.Discharge;
|
||||
import malte0811.industrialwires.client.ClientEventHandler;
|
||||
import malte0811.industrialwires.util.MiscUtils;
|
||||
import malte0811.industrialWires.blocks.IWProperties;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx.Discharge;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -32,10 +34,9 @@ import net.minecraft.util.math.Vec3d;
|
|||
import net.minecraft.util.math.Vec3i;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static malte0811.industrialwires.blocks.hv.TileEntityMarx.FiringState.FIRE;
|
||||
import static malte0811.industrialWires.blocks.hv.TileEntityMarx.FiringState.FIRE;
|
||||
|
||||
public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
||||
public static boolean screenShot = false;
|
||||
@Override
|
||||
public void render(TileEntityMarx te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
|
||||
final boolean debug = false;
|
||||
|
@ -52,23 +53,19 @@ public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
|||
//draw firing spark gaps
|
||||
Vec3i facing = te.facing.getDirectionVec();
|
||||
Vec3d offset = new Vec3d(MiscUtils.offset(BlockPos.ORIGIN, te.facing, te.mirrored, 1, 1, 0));
|
||||
offset = offset.add(-.5 * oneSgn(offset.x), 0, -.5 * oneSgn(offset.z));
|
||||
offset = offset.addVector(-.5*oneSgn(offset.x), 0, -.5*oneSgn(offset.z));
|
||||
final float pos = .3125F;
|
||||
Vec3d gapDir = new Vec3d(facing.getZ()*(te.mirrored?-1:1), 1, facing.getX()*(te.mirrored?1:-1));
|
||||
Vec3d up = new Vec3d(gapDir.x, -1, gapDir.z);
|
||||
Vec3d bottomGap = new Vec3d(offset.x+facing.getX()*pos+.5, offset.y+.75, offset.z+facing.getZ() * pos+.5);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x + bottomGap.x, y + bottomGap.y, z + bottomGap.z);
|
||||
bottomGap = bottomGap.add(te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
bottomGap = bottomGap.addVector(te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
for (int i = 0; i < te.getStageCount() - 1; i++) {
|
||||
renderGap(i, facing, vb, tes, player, gapDir, up, bottomGap, te.mirrored);
|
||||
}
|
||||
cleanUp();
|
||||
te.state = TileEntityMarx.FiringState.CHARGING;
|
||||
if (screenShot) {
|
||||
ClientEventHandler.shouldScreenshot = true;
|
||||
screenShot = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +82,7 @@ public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
|||
player = player.subtract(bottomGap.x, bottomGap.y+i, bottomGap.z);
|
||||
double t = player.dotProduct(gapDir)/2;
|
||||
Vec3d lineToPlayer = gapDir.scale(t).subtract(player);
|
||||
double angleRad = Math.acos(up.dotProduct(lineToPlayer) / (up.length() * lineToPlayer.length()));
|
||||
double angleRad = Math.acos(up.dotProduct(lineToPlayer)/(up.lengthVector()*lineToPlayer.lengthVector()));
|
||||
angleRad *= Math.signum(lineToPlayer.dotProduct(new Vec3d(facing)));
|
||||
float angle = (float) (Math.toDegrees(angleRad));
|
||||
if (facing.getZ()<0) {
|
|
@ -1,19 +1,4 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.compat;
|
||||
package malte0811.industrialWires.compat;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import crafttweaker.CraftTweakerAPI;
|
||||
|
@ -23,8 +8,8 @@ import crafttweaker.api.item.IIngredient;
|
|||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.minecraft.CraftTweakerMC;
|
||||
import crafttweaker.api.oredict.IOreDictEntry;
|
||||
import malte0811.industrialwires.hv.MarxOreHandler;
|
||||
import malte0811.industrialwires.hv.MarxOreHandler.OreChecker;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler.OreChecker;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
66
src/main/java/malte0811/industrialWires/compat/Compat.java
Normal file
66
src/main/java/malte0811/industrialWires/compat/Compat.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package malte0811.industrialWires.compat;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.api.tool.ToolboxHandler;
|
||||
import crafttweaker.CraftTweakerAPI;
|
||||
import ic2.api.item.IBoxable;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Compat {
|
||||
public static Consumer<MarxOreHandler.OreInfo> addMarx = (o)->{};
|
||||
public static Consumer<MarxOreHandler.OreInfo> removeMarx = (o)->{};
|
||||
|
||||
public static void preInit() {
|
||||
callAllForClass(PreInit.class);
|
||||
}
|
||||
public static void init() {
|
||||
callAllForClass(Init.class);
|
||||
}
|
||||
|
||||
private static void callAllForClass(Class c) {
|
||||
Method[] methods = c.getDeclaredMethods();
|
||||
for (Method m : methods) {
|
||||
if (m.getReturnType() == void.class && m.getParameterCount() == 0) {
|
||||
try {
|
||||
m.setAccessible(true);
|
||||
m.invoke(null);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class PreInit {
|
||||
@Optional.Method(modid = "crafttweaker")
|
||||
private static void preInitCraftTweaker() {
|
||||
CraftTweakerAPI.registerClass(CTMarxGenerator.class);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Init {
|
||||
@Optional.Method(modid = "ic2")
|
||||
private static void initIC2() {
|
||||
Item tinnedFood = IC2Items.getItem("filled_tin_can").getItem();
|
||||
ItemStack emptyMug = IC2Items.getItem("mug", "empty");
|
||||
ToolboxHandler.addFoodType((s) -> s.getItem() == tinnedFood);
|
||||
ToolboxHandler.addFoodType((s) ->
|
||||
s.getItem() == emptyMug.getItem() && !ItemStack.areItemStacksEqual(emptyMug, ApiUtils.copyStackWithAmount(s, 1))
|
||||
);
|
||||
Item cable = IC2Items.getItem("cable", "type:copper,insulation:0").getItem();
|
||||
ToolboxHandler.addWiringType((s, w) -> s.getItem() == cable);
|
||||
ToolboxHandler.addToolType((s) -> {
|
||||
Item a = s.getItem();
|
||||
return a instanceof IBoxable && ((IBoxable) a).canBeStoredInToolbox(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +1,11 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.compat;
|
||||
package malte0811.industrialWires.compat;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.hv.BlockTypes_HVMultiblocks;
|
||||
import malte0811.industrialwires.hv.MarxOreHandler;
|
||||
import malte0811.industrialwires.hv.MarxOreHandler.OreInfo;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.hv.BlockTypes_HVMultiblocks;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler.OreInfo;
|
||||
import mezz.jei.api.*;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
|
@ -1,21 +1,24 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.containers;
|
||||
package malte0811.industrialWires.containers;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.util.EnumHand;
|
|
@ -1,24 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.containers;
|
||||
package malte0811.industrialWires.containers;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import malte0811.industrialwires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
|
@ -1,35 +1,38 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.containers;
|
||||
package malte0811.industrialWires.containers;
|
||||
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityRSPanel;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ContainerRSPanelConn extends Container {
|
||||
private final TileEntityRSPanel te;
|
||||
private final TileEntityRSPanelConn te;
|
||||
|
||||
public ContainerRSPanelConn(TileEntityRSPanel tile) {
|
||||
public ContainerRSPanelConn(TileEntityRSPanelConn tile) {
|
||||
te = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(@Nonnull EntityPlayer playerIn) {
|
||||
return playerIn.getDistanceSq(te.getBlockPos()) < 64;
|
||||
return playerIn.getDistanceSq(te.getPos()) < 64;
|
||||
}
|
||||
}
|
|
@ -1,21 +1,24 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.containers;
|
||||
package malte0811.industrialWires.containers;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.util.EnumHand;
|
|
@ -1,24 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
|
@ -31,8 +35,6 @@ import org.lwjgl.util.vector.Vector3f;
|
|||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.COLOR;
|
||||
|
||||
public class CoveredToggleSwitch extends ToggleSwitch {
|
||||
private int color = 0xff0000;
|
||||
private SwitchState state = SwitchState.CLOSED;
|
||||
|
@ -61,13 +63,15 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRel, EntityPlayerMP player) {
|
||||
public void interactWith(Vec3d hitRel, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
if (player.isSneaking() && state == SwitchState.OPEN) {
|
||||
state = SwitchState.CLOSED;
|
||||
} else {
|
||||
state = state.next();
|
||||
}
|
||||
setOut(state.active);
|
||||
setOut(state.active, tile);
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,18 +84,20 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
|
||||
@Override
|
||||
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
|
||||
super.writeCustomNBT(nbt, toItem);
|
||||
if (!toItem) {
|
||||
nbt.setInteger("state", state.ordinal());
|
||||
}
|
||||
nbt.setByte(RS_CHANNEL, rsOutputChannel);
|
||||
nbt.setInteger(RS_ID, rsOutputId);
|
||||
nbt.setInteger(COLOR, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readCustomNBT(NBTTagCompound nbt) {
|
||||
super.readCustomNBT(nbt);
|
||||
state = SwitchState.values()[nbt.getInteger("state")];
|
||||
color = nbt.getInteger(COLOR);
|
||||
rsOutputChannel = nbt.getByte(RS_CHANNEL);
|
||||
rsOutputId = nbt.getInteger(RS_ID);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -100,7 +106,8 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
CoveredToggleSwitch ret = new CoveredToggleSwitch();
|
||||
ret.color = color;
|
||||
ret.state = state;
|
||||
ret.outputChannel = outputChannel;
|
||||
ret.rsOutputChannel = rsOutputChannel;
|
||||
ret.rsOutputId = rsOutputId;
|
||||
ret.active = active;
|
||||
ret.setX(getX());
|
||||
ret.setY(getY());
|
||||
|
@ -129,7 +136,6 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
if (type == ConfigType.FLOAT) {
|
||||
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : "blue")));
|
||||
|
@ -138,7 +144,6 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
if (type == ConfigType.FLOAT) {
|
||||
return null;
|
||||
|
@ -159,15 +164,20 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
|
||||
CoveredToggleSwitch that = (CoveredToggleSwitch) o;
|
||||
|
||||
if (rsOutputId != that.rsOutputId) return false;
|
||||
if (rsOutputChannel != that.rsOutputChannel) return false;
|
||||
if (color != that.color) return false;
|
||||
return state == that.state;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + rsOutputId;
|
||||
result = 31 * result + (int) rsOutputChannel;
|
||||
result = 31 * result + color;
|
||||
result = 31 * result + state.hashCode();
|
||||
result = 31 * result + (state != null ? state.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1,24 +1,25 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -33,22 +34,20 @@ public interface IConfigurableComponent {
|
|||
* @return a TRANSLATED name for the config option. Try to keep this short.
|
||||
*/
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
String fomatConfigName(ConfigType type, int id);
|
||||
|
||||
/**
|
||||
* @return a TRANSLATED name for the config option, displayed when hovering over it
|
||||
*/
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
String fomatConfigDescription(ConfigType type, int id);
|
||||
|
||||
default StringConfig[] getStringOptions() {
|
||||
return new StringConfig[0];
|
||||
}
|
||||
|
||||
default RSColorConfig[] getRSChannelOptions() {
|
||||
return new RSColorConfig[0];
|
||||
default RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[0];
|
||||
}
|
||||
|
||||
default IntConfig[] getIntegerOptions() {
|
||||
|
@ -84,14 +83,14 @@ public interface IConfigurableComponent {
|
|||
}
|
||||
}
|
||||
|
||||
class RSColorConfig extends UniversalConfig<Byte> {
|
||||
class RSChannelConfig extends UniversalConfig<Byte> {
|
||||
public boolean small;
|
||||
|
||||
public RSColorConfig(String name, int x, int y, Byte value) {
|
||||
public RSChannelConfig(String name, int x, int y, Byte value) {
|
||||
this(name, x, y, value, false);
|
||||
}
|
||||
|
||||
public RSColorConfig(String name, int x, int y, Byte value, boolean small) {
|
||||
public RSChannelConfig(String name, int x, int y, Byte value, boolean small) {
|
||||
super(name, x, y, value);
|
||||
this.small = small;
|
||||
}
|
|
@ -1,28 +1,33 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -36,11 +41,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
|
||||
public class IndicatorLight extends PanelComponent implements IConfigurableComponent {
|
||||
@Nonnull
|
||||
private RSChannel inputChannel = RSChannel.DEFAULT_CHANNEL;
|
||||
private int rsInputId;
|
||||
private byte rsInputChannel;
|
||||
private int colorA = 0xff00;
|
||||
private byte rsInput;
|
||||
|
||||
|
@ -48,16 +51,17 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
super("indicator_light");
|
||||
}
|
||||
|
||||
public IndicatorLight(@Nonnull RSChannel input, int color) {
|
||||
public IndicatorLight(int rsId, byte rsChannel, int color) {
|
||||
this();
|
||||
colorA = color;
|
||||
inputChannel = input;
|
||||
rsInputChannel = rsChannel;
|
||||
rsInputId = rsId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
|
||||
nbt.setInteger(RS_ID, inputChannel.getController());
|
||||
nbt.setByte(RS_CHANNEL, inputChannel.getColor());
|
||||
nbt.setInteger(RS_ID, rsInputId);
|
||||
nbt.setByte(RS_CHANNEL, rsInputChannel);
|
||||
nbt.setInteger(COLOR, colorA);
|
||||
if (!toItem) {
|
||||
nbt.setInteger("rsInput", rsInput);
|
||||
|
@ -66,9 +70,8 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
|
||||
@Override
|
||||
protected void readCustomNBT(NBTTagCompound nbt) {
|
||||
int rsController = nbt.getInteger(RS_ID);
|
||||
byte rsColor = nbt.getByte(RS_CHANNEL);
|
||||
inputChannel = new RSChannel(rsController, rsColor);
|
||||
rsInputId = nbt.getInteger(RS_ID);
|
||||
rsInputChannel = nbt.getByte(RS_CHANNEL);
|
||||
colorA = nbt.getInteger(COLOR);
|
||||
rsInput = nbt.getByte("rsInput");
|
||||
}
|
||||
|
@ -94,7 +97,7 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
@Nonnull
|
||||
@Override
|
||||
public PanelComponent copyOf() {
|
||||
IndicatorLight ret = new IndicatorLight(inputChannel, colorA);
|
||||
IndicatorLight ret = new IndicatorLight(rsInputId, rsInputChannel, colorA);
|
||||
ret.rsInput = rsInput;
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
|
@ -112,27 +115,31 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRelative, EntityPlayerMP player) {
|
||||
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update(TileEntityPanel tile) {
|
||||
|
||||
}
|
||||
|
||||
private Consumer<ControlPanelNetwork.RSChannelState> handler = (state) -> {
|
||||
if (state.getStrength() != rsInput) {
|
||||
rsInput = state.getStrength();
|
||||
private TileEntityPanel panel;
|
||||
private Consumer<byte[]> handler = (input) -> {
|
||||
if (input[rsInputChannel] != rsInput) {
|
||||
rsInput = input[rsInputChannel];
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void setNetwork(ControlPanelNetwork net) {
|
||||
super.setNetwork(net);
|
||||
net.addListener(this, handler, inputChannel);
|
||||
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
|
||||
if (matchesId(rsInputId, id)) {
|
||||
this.panel = panel;
|
||||
return handler;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -169,16 +176,12 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
@Override
|
||||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
if (id == 0) {
|
||||
inputChannel = inputChannel.withColor(value);
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id == 0) {
|
||||
inputChannel = inputChannel.withController(value);
|
||||
}
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
rsInputChannel = ((NBTTagByte) value).getByte();
|
||||
break;
|
||||
case INT:
|
||||
rsInputId = ((NBTTagInt) value).getInt();
|
||||
break;
|
||||
case FLOAT:
|
||||
colorA = PanelUtils.setColor(colorA, id, value);
|
||||
break;
|
||||
|
@ -187,7 +190,6 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
|
@ -201,7 +203,6 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
|
@ -216,16 +217,16 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
}
|
||||
|
||||
@Override
|
||||
public RSColorConfig[] getRSChannelOptions() {
|
||||
return new RSColorConfig[]{
|
||||
new RSColorConfig("channel", 0, 0, inputChannel.getColor())
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{
|
||||
new RSChannelConfig("channel", 0, 0, rsInputChannel)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{
|
||||
new IntConfig("rsId", 0, 45, inputChannel.getController(), 2, false)
|
||||
new IntConfig("rsId", 0, 45, rsInputId, 2, false)
|
||||
};
|
||||
}
|
||||
|
|
@ -1,24 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.client.panelmodel.RawModelFontRenderer;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.client.panelmodel.RawModelFontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
@ -35,9 +39,6 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.COLOR;
|
||||
import static malte0811.industrialwires.util.NBTKeys.TEXT;
|
||||
|
||||
public class Label extends PanelComponent implements IConfigurableComponent {
|
||||
private String text = "Test";
|
||||
private int color = 0x808080;
|
||||
|
@ -100,12 +101,12 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRelative, EntityPlayerMP player) {
|
||||
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
//NOP
|
||||
public void update(TileEntityPanel tile) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,7 +146,6 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
|
@ -157,7 +157,6 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case STRING:
|
|
@ -1,32 +1,37 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannelState;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.util.TriConsumer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
|
@ -34,27 +39,25 @@ import javax.annotation.Nonnull;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
import static net.minecraftforge.fml.relauncher.Side.CLIENT;
|
||||
|
||||
public class LightedButton extends PanelComponent implements IConfigurableComponent {
|
||||
public int color = 0xFF0000;
|
||||
private boolean active;
|
||||
private boolean latching;
|
||||
@Nonnull
|
||||
private RSChannel outputChannel = RSChannel.DEFAULT_CHANNEL;
|
||||
public boolean active;
|
||||
public boolean latching;
|
||||
public int rsOutputId;
|
||||
public int rsOutputChannel;
|
||||
private int ticksTillOff;
|
||||
|
||||
LightedButton() {
|
||||
public LightedButton() {
|
||||
super("lighted_button");
|
||||
}
|
||||
|
||||
public LightedButton(int color, boolean active, boolean latching, @Nonnull RSChannel out) {
|
||||
public LightedButton(int color, boolean active, boolean latching, int rsOutputId, int rsOutputChannel) {
|
||||
this();
|
||||
this.color = color;
|
||||
this.active = active;
|
||||
this.latching = latching;
|
||||
this.outputChannel = out;
|
||||
this.rsOutputChannel = rsOutputChannel;
|
||||
this.rsOutputId = rsOutputId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,8 +68,8 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
nbt.setBoolean("active", active);
|
||||
}
|
||||
nbt.setBoolean(LATCHING, latching);
|
||||
nbt.setByte(RS_CHANNEL, outputChannel.getColor());
|
||||
nbt.setInteger(RS_ID, outputChannel.getController());
|
||||
nbt.setInteger(RS_CHANNEL, rsOutputChannel);
|
||||
nbt.setInteger(RS_ID, rsOutputId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,15 +78,14 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
ticksTillOff = nbt.getInteger("timeout");
|
||||
active = nbt.getBoolean("active");
|
||||
latching = nbt.getBoolean(LATCHING);
|
||||
byte rsOutputChannel = nbt.getByte(RS_CHANNEL);
|
||||
int rsOutputId = nbt.getInteger(RS_ID);
|
||||
this.outputChannel = new RSChannel(rsOutputId, rsOutputChannel);
|
||||
rsOutputChannel = nbt.getInteger(RS_CHANNEL);
|
||||
rsOutputId = nbt.getInteger(RS_ID);
|
||||
}
|
||||
|
||||
private final static float size = .0625F;
|
||||
|
||||
@Override
|
||||
@SideOnly(CLIENT)
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
float[] color = PanelUtils.getFloatColor(active, this.color);
|
||||
List<RawQuad> ret = new ArrayList<>(5);
|
||||
|
@ -98,7 +100,7 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
@Override
|
||||
@Nonnull
|
||||
public PanelComponent copyOf() {
|
||||
LightedButton ret = new LightedButton(color, active, latching, outputChannel);
|
||||
LightedButton ret = new LightedButton(color, active, latching, rsOutputId, rsOutputChannel);
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.panelHeight = panelHeight;
|
||||
|
@ -115,34 +117,36 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRel, EntityPlayerMP player) {
|
||||
public void interactWith(Vec3d hitRel, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
if (!latching && active) {
|
||||
ticksTillOff = 10;
|
||||
} else {
|
||||
setOut(!active);
|
||||
setOut(!active, tile);
|
||||
if (!latching) {
|
||||
ticksTillOff = 10;
|
||||
}
|
||||
}
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!latching && active) {
|
||||
public void update(TileEntityPanel tile) {
|
||||
if (!latching && ticksTillOff > 0) {
|
||||
ticksTillOff--;
|
||||
panel.markDirty();
|
||||
if (ticksTillOff <= 0) {
|
||||
setOut(false);
|
||||
tile.markDirty();
|
||||
if (ticksTillOff == 0) {
|
||||
setOut(false, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(ControlPanelNetwork net) {
|
||||
super.setNetwork(net);
|
||||
net.setOutputs(this, new RSChannelState(outputChannel, (byte) (active?15:0)));
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (matchesId(rsOutputId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept(rsOutputChannel, (byte) (active ? 15 : 0), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,16 +155,21 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(CLIENT)
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
renderInGUIDefault(gui, 0xff000000 | color);
|
||||
}
|
||||
|
||||
private void setOut(boolean on) {
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
setOut(rsOutputChannel, 0);
|
||||
}
|
||||
|
||||
private void setOut(boolean on, TileEntityPanel tile) {
|
||||
active = on;
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
network.setOutputs(this, new RSChannelState(outputChannel, (byte)(active?15:0)));
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
setOut(rsOutputChannel, active ? 15 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -195,12 +204,12 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id == 0) {
|
||||
outputChannel = outputChannel.withColor(value);
|
||||
rsOutputChannel = ((NBTTagByte) value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id == 0) {
|
||||
outputChannel = outputChannel.withController(value);
|
||||
rsOutputId = ((NBTTagInt) value).getInt();
|
||||
}
|
||||
break;
|
||||
case FLOAT:
|
||||
|
@ -210,7 +219,6 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(CLIENT)
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
|
@ -226,7 +234,6 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(CLIENT)
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
|
@ -243,14 +250,13 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
}
|
||||
|
||||
@Override
|
||||
public RSColorConfig[] getRSChannelOptions() {
|
||||
return new RSColorConfig[]{new RSColorConfig("channel", 0, 0, outputChannel.getColor())};
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{new RSChannelConfig("channel", 0, 0, (byte) rsOutputChannel)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{new IntConfig("rsId", 0, 50,
|
||||
outputChannel.getController(), 2, false)};
|
||||
return new IntConfig[]{new IntConfig("rsId", 0, 50, rsOutputId, 2, false)};
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,27 +1,30 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannelState;
|
||||
import malte0811.industrialwires.items.ItemKey;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.items.ItemKey;
|
||||
import malte0811.industrialWires.util.TriConsumer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
@ -45,16 +48,14 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
|
||||
public class Lock extends PanelComponent implements IConfigurableComponent {
|
||||
private final static Random rand = new Random();
|
||||
@Nullable
|
||||
private NBTTagCompound keyNBT;
|
||||
private boolean turned;
|
||||
private boolean latching = false;
|
||||
@Nonnull
|
||||
private RSChannel outputChannel = RSChannel.DEFAULT_CHANNEL;
|
||||
private int rsOutputId;
|
||||
private int rsOutputChannel;
|
||||
private int ticksTillOff;
|
||||
private int lockID;
|
||||
|
||||
|
@ -65,10 +66,11 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public Lock(boolean latching, @Nonnull RSChannel out) {
|
||||
public Lock(boolean latching, int rsOutputId, int rsOutputChannel) {
|
||||
this();
|
||||
this.latching = latching;
|
||||
outputChannel = out;
|
||||
this.rsOutputChannel = rsOutputChannel;
|
||||
this.rsOutputId = rsOutputId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,8 +84,8 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
nbt.setInteger("lockId", lockID);
|
||||
nbt.setBoolean(LATCHING, latching);
|
||||
nbt.setByte(RS_CHANNEL, outputChannel.getColor());
|
||||
nbt.setInteger(RS_ID, outputChannel.getController());
|
||||
nbt.setInteger(RS_CHANNEL, rsOutputChannel);
|
||||
nbt.setInteger(RS_ID, rsOutputId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,15 +101,8 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
lockID = nbt.getInteger("lockId");
|
||||
}
|
||||
latching = nbt.getBoolean(LATCHING);
|
||||
int rsController = nbt.getInteger(RS_CHANNEL);
|
||||
byte rsColor = nbt.getByte(RS_ID);
|
||||
outputChannel = new RSChannel(rsController, rsColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(ControlPanelNetwork net) {
|
||||
super.setNetwork(net);
|
||||
net.setOutputs(this, new RSChannelState(outputChannel, (byte) (turned?15:0)));
|
||||
rsOutputChannel = nbt.getInteger(RS_CHANNEL);
|
||||
rsOutputId = nbt.getInteger(RS_ID);
|
||||
}
|
||||
|
||||
private final static float size = .0625F;
|
||||
|
@ -143,7 +138,6 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void addKey(List<RawQuad> out, Matrix4 mat) {
|
||||
PanelUtils.addColoredBox(DARK_GRAY, DARK_GRAY, null, new Vector3f(xOffset, size / 2, zOffsetLowerKey), new Vector3f(keyWidth, keyOffset, size / 2), out, false, mat);
|
||||
PanelUtils.addColoredBox(DARK_GRAY, DARK_GRAY, null, new Vector3f(xOffset, size / 2 + keyOffset, zOffset), new Vector3f(keyWidth, size, size - 2 * zOffset), out, false, mat);
|
||||
|
@ -152,7 +146,7 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
@Override
|
||||
@Nonnull
|
||||
public PanelComponent copyOf() {
|
||||
Lock ret = new Lock(latching, outputChannel);
|
||||
Lock ret = new Lock(latching, rsOutputId, rsOutputChannel);
|
||||
ret.turned = turned;
|
||||
ret.lockID = lockID;
|
||||
ret.keyNBT = keyNBT == null ? null : keyNBT.copy();
|
||||
|
@ -173,7 +167,7 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRel, EntityPlayerMP player) {
|
||||
public void interactWith(Vec3d hitRel, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
boolean update = false;
|
||||
if (keyNBT == null) {
|
||||
for (EnumHand hand : EnumHand.values()) {
|
||||
|
@ -201,25 +195,34 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
}
|
||||
if (update) {
|
||||
setOut();
|
||||
setOut(tile);
|
||||
if (!latching && turned) {
|
||||
ticksTillOff = 10;
|
||||
}
|
||||
}
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update(TileEntityPanel tile) {
|
||||
if (!latching && ticksTillOff > 0) {
|
||||
ticksTillOff--;
|
||||
tile.markDirty();
|
||||
if (ticksTillOff == 0) {
|
||||
turned = false;
|
||||
panel.triggerRenderUpdate();
|
||||
setOut();
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
setOut(tile);
|
||||
}
|
||||
panel.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (matchesId(rsOutputId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept(rsOutputChannel, (byte) (turned ? 15 : 0), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,15 +243,22 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
Gui.drawRect(left, top, right, bottom, DARK_GRAY_INT);
|
||||
}
|
||||
|
||||
private void setOut() {
|
||||
network.setOutputs(this, new RSChannelState(outputChannel, (byte) (turned ? 15 : 0)));
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
setOut(rsOutputChannel, 0);
|
||||
}
|
||||
|
||||
private void setOut(TileEntityPanel tile) {
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
setOut(rsOutputChannel, turned ? 15 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropItems() {
|
||||
super.dropItems();
|
||||
public void dropItems(TileEntityPanel te) {
|
||||
super.dropItems(te);
|
||||
if (keyNBT!=null) {
|
||||
Block.spawnAsEntity(panel.getWorld(), panel.getBlockPos(), new ItemStack(keyNBT));
|
||||
Block.spawnAsEntity(te.getWorld(), te.getPos(), new ItemStack(keyNBT));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,10 +272,11 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
if (turned != lock.turned) return false;
|
||||
if (latching != lock.latching) return false;
|
||||
if (rsOutputId != lock.rsOutputId) return false;
|
||||
if (rsOutputChannel != lock.rsOutputChannel) return false;
|
||||
if (ticksTillOff != lock.ticksTillOff) return false;
|
||||
if (lockID != lock.lockID) return false;
|
||||
if (keyNBT != null ? !keyNBT.equals(lock.keyNBT) : lock.keyNBT != null) return false;
|
||||
return outputChannel.equals(lock.outputChannel);
|
||||
return keyNBT != null ? keyNBT.equals(lock.keyNBT) : lock.keyNBT == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -274,7 +285,8 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
result = 31 * result + (keyNBT != null ? keyNBT.hashCode() : 0);
|
||||
result = 31 * result + (turned ? 1 : 0);
|
||||
result = 31 * result + (latching ? 1 : 0);
|
||||
result = 31 * result + outputChannel.hashCode();
|
||||
result = 31 * result + rsOutputId;
|
||||
result = 31 * result + rsOutputChannel;
|
||||
result = 31 * result + ticksTillOff;
|
||||
result = 31 * result + lockID;
|
||||
return result;
|
||||
|
@ -283,28 +295,25 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
@Override
|
||||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
if (id == 0) {
|
||||
latching = ((NBTTagByte) value).getByte() != 0;
|
||||
}
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id == 0) {
|
||||
byte rsColor = ((NBTTagByte) value).getByte();
|
||||
outputChannel = new RSChannel(outputChannel.getController(), rsColor);
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id == 0) {
|
||||
int rsController = ((NBTTagInt) value).getInt();
|
||||
outputChannel = new RSChannel(rsController, outputChannel.getColor());
|
||||
}
|
||||
break;
|
||||
case BOOL:
|
||||
if (id == 0) {
|
||||
latching = ((NBTTagByte) value).getByte() != 0;
|
||||
}
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id == 0) {
|
||||
rsOutputChannel = ((NBTTagByte) value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id == 0) {
|
||||
rsOutputId = ((NBTTagInt) value).getInt();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
|
@ -318,7 +327,6 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
|
@ -333,13 +341,13 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RSColorConfig[] getRSChannelOptions() {
|
||||
return new RSColorConfig[]{new RSColorConfig("channel", 0, 0, outputChannel.getColor())};
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{new RSChannelConfig("channel", 0, 0, (byte) rsOutputChannel)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{new IntConfig("rsId", 0, 50, outputChannel.getController(), 2, false)};
|
||||
return new IntConfig[]{new IntConfig("rsId", 0, 50, rsOutputId, 2, false)};
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
public enum MessageType {
|
||||
ADD,
|
|
@ -1,59 +1,70 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.IOwner;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.util.TriConsumer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class PanelComponent implements IOwner {
|
||||
public abstract class PanelComponent {
|
||||
public static final float Y_DELTA = .001F;
|
||||
protected static final float[] GRAY = {.8F, .8F, .8F};
|
||||
protected static final int GRAY_INT = 0xFFD0D0D0;
|
||||
protected static final float[] BLACK = {0, 0, 0, 1};
|
||||
protected float panelHeight;
|
||||
protected AxisAlignedBB aabb = null;
|
||||
protected float x, y;
|
||||
private final String type;
|
||||
protected TileEntityPanel panel;
|
||||
protected ControlPanelNetwork network;
|
||||
protected final static float[] GRAY = {.8F, .8F, .8F};
|
||||
protected final static int GRAY_INT = 0xFFD0D0D0;
|
||||
protected static final float[] BLACK = {0, 0, 0, 1};
|
||||
|
||||
private Set<TriConsumer<Integer, Byte, PanelComponent>> outputs = new HashSet<>();
|
||||
|
||||
protected PanelComponent(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static final Map<String, Supplier<PanelComponent>> baseCreaters = new HashMap<>();
|
||||
public final static String COLOR = "color";
|
||||
public final static String RS_CHANNEL = "rsChannel";
|
||||
public final static String RS_ID = "rsId";
|
||||
public final static String RS_CHANNEL2 = "rsChannel2";
|
||||
public final static String RS_ID2 = "rsId2";
|
||||
public final static String TEXT = "text";
|
||||
public static final String HORIZONTAL = "horizontal";
|
||||
public static final String LENGTH = "length";
|
||||
public static final String LATCHING = "latching";
|
||||
|
||||
public static void init() {
|
||||
baseCreaters.put("lighted_button", LightedButton::new);
|
||||
|
@ -66,7 +77,6 @@ public abstract class PanelComponent implements IOwner {
|
|||
baseCreaters.put("lock", Lock::new);
|
||||
baseCreaters.put("panel_meter", PanelMeter::new);
|
||||
baseCreaters.put(SevenSegDisplay.NAME, SevenSegDisplay::new);
|
||||
baseCreaters.put("rgb_led", RGBIndicator::new);
|
||||
//Check that all components implement equals+hashCode if in a dev env
|
||||
boolean isDevEnv = "NBTTagCompound".equals(NBTTagCompound.class.getSimpleName());
|
||||
if (isDevEnv) {
|
||||
|
@ -97,19 +107,33 @@ public abstract class PanelComponent implements IOwner {
|
|||
@Nonnull
|
||||
public abstract AxisAlignedBB getBlockRelativeAABB();
|
||||
|
||||
public abstract void interactWith(Vec3d hitRelative, EntityPlayerMP player);
|
||||
public abstract void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player);
|
||||
|
||||
public abstract void update();
|
||||
public abstract void update(TileEntityPanel tile);
|
||||
|
||||
public abstract int getColor();
|
||||
|
||||
public abstract float getHeight();
|
||||
|
||||
public void setNetwork(ControlPanelNetwork net) {
|
||||
this.network = net;
|
||||
@Nullable
|
||||
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void dropItems() {
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
outputs.add(out);
|
||||
}
|
||||
|
||||
public void unregisterRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
outputs.remove(out);
|
||||
}
|
||||
|
||||
protected boolean matchesId(int myId, int theirId) {
|
||||
return myId==theirId||theirId<0;
|
||||
}
|
||||
|
||||
public void dropItems(TileEntityPanel te) {
|
||||
}
|
||||
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
|
@ -120,6 +144,8 @@ public abstract class PanelComponent implements IOwner {
|
|||
return y;
|
||||
}
|
||||
|
||||
public abstract float getHeight();
|
||||
|
||||
public void setX(float x) {
|
||||
this.x = x;
|
||||
aabb = null;
|
||||
|
@ -134,11 +160,6 @@ public abstract class PanelComponent implements IOwner {
|
|||
this.panelHeight = panelHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getBlockPos() {
|
||||
return panel.getPos();
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt, boolean toItem) {
|
||||
writeCustomNBT(nbt, toItem);
|
||||
nbt.setFloat("x", getX());
|
||||
|
@ -166,6 +187,38 @@ public abstract class PanelComponent implements IOwner {
|
|||
setPanelHeight(nbt.getFloat("panelHeight"));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderBox(TileEntityPanel te) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.glLineWidth(2.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
te.getComponents().transformGLForTop(te.getPos());
|
||||
RenderGlobal.drawSelectionBoundingBox(getBlockRelativeAABB().grow(0.002),
|
||||
0.0F, 0.0F, 0.0F, 0.4F);
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void renderInGUI(GuiPanelCreator gui);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUIDefault(GuiPanelCreator gui, int color) {
|
||||
color |= 0xff000000;
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
int left = (int) (gui.getX0() + aabb.minX * gui.panelSize);
|
||||
int top = (int) (gui.getY0() + aabb.minZ * gui.panelSize);
|
||||
int right = (int) (gui.getX0() + aabb.maxX * gui.panelSize);
|
||||
int bottom = (int) (gui.getY0() + aabb.maxZ * gui.panelSize);
|
||||
Gui.drawRect(left, top, right, bottom, color);
|
||||
}
|
||||
|
||||
|
||||
public boolean isValidPos(List<PanelComponent> components, float height, float angle) {
|
||||
float h = PanelUtils.getHeightWithComponent(this, angle, height);
|
||||
if (h < 0 || h > 1) {
|
||||
|
@ -192,38 +245,12 @@ public abstract class PanelComponent implements IOwner {
|
|||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderBox() {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.glLineWidth(2.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
panel.getComponents().transformGLForTop(panel.getBlockPos());
|
||||
RenderGlobal.drawSelectionBoundingBox(getBlockRelativeAABB().grow(0.002),
|
||||
0.0F, 0.0F, 0.0F, 0.4F);
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
void setOut(int channel, int level) {
|
||||
for (TriConsumer<Integer, Byte, PanelComponent> out : outputs) {
|
||||
out.accept(channel, (byte) level, this);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void renderInGUI(GuiPanelCreator gui);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUIDefault(GuiPanelCreator gui, int color) {
|
||||
color |= 0xff000000;
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
int left = (int) (gui.getX0() + aabb.minX * gui.panelSize);
|
||||
int top = (int) (gui.getY0() + aabb.minZ * gui.panelSize);
|
||||
int right = (int) (gui.getX0() + aabb.maxX * gui.panelSize);
|
||||
int bottom = (int) (gui.getY0() + aabb.maxZ * gui.panelSize);
|
||||
Gui.drawRect(left, top, right, bottom, color);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -245,8 +272,4 @@ public abstract class PanelComponent implements IOwner {
|
|||
result = 31 * result + type.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setPanel(TileEntityPanel tile) {
|
||||
panel = tile;
|
||||
}
|
||||
}
|
|
@ -1,27 +1,29 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.client.panelmodel.RawModelFontRenderer;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannelState;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.client.panelmodel.RawModelFontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
@ -29,6 +31,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -42,33 +45,35 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
|
||||
public class PanelMeter extends PanelComponent implements IConfigurableComponent {
|
||||
@Nonnull
|
||||
private RSChannel primary = RSChannel.DEFAULT_CHANNEL;
|
||||
@Nonnull
|
||||
private RSChannel secondary = RSChannel.INVALID_CHANNEL;
|
||||
public static final String WIDE = "wide";
|
||||
|
||||
private int rsInputId, rsInputId2 = -1;
|
||||
private byte rsInputChannel, rsInputChannel2;
|
||||
private int rsInput;
|
||||
private boolean wide = true;
|
||||
private boolean hasSecond;
|
||||
|
||||
public PanelMeter() {
|
||||
super("panel_meter");
|
||||
}
|
||||
|
||||
public PanelMeter(@Nonnull RSChannel primary, @Nonnull RSChannel secondary, boolean wide) {
|
||||
public PanelMeter(int rsId, byte rsChannel, int rsId2, byte rsChannel2, boolean wide, boolean hasSecond) {
|
||||
this();
|
||||
this.primary = primary;
|
||||
this.secondary = secondary;
|
||||
rsInputChannel = rsChannel;
|
||||
rsInputId = rsId;
|
||||
rsInputChannel2 = rsChannel2;
|
||||
rsInputId2 = rsId2;
|
||||
this.hasSecond = hasSecond;
|
||||
this.wide = wide;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
|
||||
nbt.setInteger(RS_ID, primary.getController());
|
||||
nbt.setByte(RS_CHANNEL, primary.getColor());
|
||||
nbt.setInteger(RS_ID2, secondary.getController());
|
||||
nbt.setByte(RS_CHANNEL2, secondary.getColor());
|
||||
nbt.setInteger(RS_ID, rsInputId);
|
||||
nbt.setByte(RS_CHANNEL, rsInputChannel);
|
||||
nbt.setInteger(RS_ID2, rsInputId2);
|
||||
nbt.setByte(RS_CHANNEL2, rsInputChannel2);
|
||||
nbt.setBoolean(WIDE, wide);
|
||||
if (!toItem) {
|
||||
nbt.setInteger("rsInput", rsInput);
|
||||
|
@ -77,17 +82,20 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
|
||||
@Override
|
||||
protected void readCustomNBT(NBTTagCompound nbt) {
|
||||
int rsController = nbt.getInteger(RS_ID);
|
||||
byte rsColor = nbt.getByte(RS_CHANNEL);
|
||||
primary = new RSChannel(rsController, rsColor);
|
||||
rsInputId = nbt.getInteger(RS_ID);
|
||||
rsInputChannel = nbt.getByte(RS_CHANNEL);
|
||||
rsInput = nbt.getInteger("rsInput");
|
||||
wide = nbt.getBoolean(WIDE);
|
||||
if (nbt.hasKey(RS_ID2)) {
|
||||
rsController = nbt.getInteger(RS_ID2);
|
||||
rsColor = nbt.getByte(RS_CHANNEL2);
|
||||
secondary = new RSChannel(rsController, rsColor);
|
||||
rsInputId2 = nbt.getInteger(RS_ID2);
|
||||
rsInputChannel2 = nbt.getByte(RS_CHANNEL2);
|
||||
hasSecond = rsInputId2>=0&&rsInputChannel2>=0;
|
||||
} else {
|
||||
secondary = RSChannel.INVALID_CHANNEL;
|
||||
hasSecond = false;
|
||||
}
|
||||
if (!hasSecond) {
|
||||
rsInputId2 = -1;
|
||||
rsInputChannel2 = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +171,7 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
@Nonnull
|
||||
@Override
|
||||
public PanelComponent copyOf() {
|
||||
PanelMeter ret = new PanelMeter(primary, secondary, wide);
|
||||
PanelMeter ret = new PanelMeter(rsInputId, rsInputChannel, rsInputId2, rsInputChannel2, wide, hasSecond);
|
||||
ret.rsInput = rsInput;
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
|
@ -181,40 +189,48 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRelative, EntityPlayerMP player) {
|
||||
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update(TileEntityPanel tile) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(ControlPanelNetwork net) {
|
||||
super.setNetwork(net);
|
||||
Consumer<RSChannelState> listenerPrimary = (input) -> {
|
||||
byte strength = input.getStrength();
|
||||
if (strength != rsInput >> 4) {
|
||||
if (secondary.isValid()) {
|
||||
rsInput = (strength << 4) | (rsInput & 0xf);
|
||||
} else {
|
||||
rsInput = strength * 17;
|
||||
}
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
}
|
||||
};
|
||||
net.addListener(this, listenerPrimary, primary);
|
||||
if (secondary.isValid()) {
|
||||
Consumer<RSChannelState> listenerSec = (input) -> {
|
||||
if (input.getStrength() != (rsInput & 0xf)) {
|
||||
rsInput = (input.getStrength() & 0xf) | (rsInput & 0xf0);
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
}
|
||||
};
|
||||
net.addListener(this, listenerSec, secondary);
|
||||
private TileEntityPanel panel;
|
||||
private Consumer<byte[]> handlerSec = (input) -> {
|
||||
if (input[rsInputChannel2] != (rsInput&0xf)) {
|
||||
rsInput = (input[rsInputChannel2]&0xf)|(rsInput&0xf0);
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
}
|
||||
};
|
||||
private Consumer<byte[]> handler = (input) -> {
|
||||
if (input[rsInputChannel] != rsInput>>4) {
|
||||
if (hasSecond) {
|
||||
rsInput = (input[rsInputChannel]<<4)|(rsInput&0xf);
|
||||
} else {
|
||||
rsInput = input[rsInputChannel]*17;
|
||||
}
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
}
|
||||
if (rsInputId2==rsInputId) {
|
||||
handlerSec.accept(input);
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
|
||||
if (matchesId(rsInputId, id)) {
|
||||
this.panel = panel;
|
||||
return handler;
|
||||
} else if (matchesId(rsInputId2, id)) {
|
||||
this.panel = panel;
|
||||
return handlerSec;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -230,19 +246,25 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
|
||||
PanelMeter that = (PanelMeter) o;
|
||||
|
||||
if (rsInputId != that.rsInputId) return false;
|
||||
if (rsInputId2 != that.rsInputId2) return false;
|
||||
if (rsInputChannel != that.rsInputChannel) return false;
|
||||
if (rsInputChannel2 != that.rsInputChannel2) return false;
|
||||
if (rsInput != that.rsInput) return false;
|
||||
if (wide != that.wide) return false;
|
||||
if (!primary.equals(that.primary)) return false;
|
||||
return secondary.equals(that.secondary);
|
||||
return hasSecond == that.hasSecond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + primary.hashCode();
|
||||
result = 31 * result + secondary.hashCode();
|
||||
result = 31 * result + rsInputId;
|
||||
result = 31 * result + rsInputId2;
|
||||
result = 31 * result + (int) rsInputChannel;
|
||||
result = 31 * result + (int) rsInputChannel2;
|
||||
result = 31 * result + rsInput;
|
||||
result = 31 * result + (wide ? 1 : 0);
|
||||
result = 31 * result + (hasSecond ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -259,6 +281,7 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
GlStateManager.pushMatrix();
|
||||
int border = (int) Math.ceil(BORDER*gui.panelSize);
|
||||
int width = right-left;
|
||||
int height = bottom-top;
|
||||
if (wide) {
|
||||
GlStateManager.translate(left+width/2D, bottom-2*border, 0);
|
||||
GlStateManager.rotate(135, 0, 0, 1);
|
||||
|
@ -279,16 +302,17 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
if (id == 0) {
|
||||
primary = primary.withColor(value);
|
||||
rsInputChannel = ((NBTTagByte) value).getByte();
|
||||
} else {
|
||||
secondary = secondary.withColor(value);
|
||||
rsInputChannel2 = ((NBTTagByte) value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id == 0) {
|
||||
primary = primary.withController(value);
|
||||
rsInputId = ((NBTTagInt) value).getInt();
|
||||
} else {
|
||||
secondary = secondary.withController(value);
|
||||
rsInputId2 = ((NBTTagInt) value).getInt();
|
||||
hasSecond = rsInputId2>=0;
|
||||
}
|
||||
break;
|
||||
case BOOL:
|
||||
|
@ -298,7 +322,6 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
|
@ -314,7 +337,6 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
|
@ -329,18 +351,18 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
}
|
||||
|
||||
@Override
|
||||
public RSColorConfig[] getRSChannelOptions() {
|
||||
return new RSColorConfig[]{
|
||||
new RSColorConfig("channel", 0, 0, primary.getColor(), false),
|
||||
new RSColorConfig("channel2", 60, 0, secondary.getColor(), false)
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{
|
||||
new RSChannelConfig("channel", 0, 0, rsInputChannel, false),
|
||||
new RSChannelConfig("channel2", 60, 0, rsInputChannel2, false)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{
|
||||
new IntConfig("rsId", 0, 60, primary.getController(), 2, false),
|
||||
new IntConfig("rsId2", 60, 60, secondary.getController(), 2, true)
|
||||
new IntConfig("rsId", 0, 60, rsInputId, 2, false),
|
||||
new IntConfig("rsId2", 60, 60, rsInputId2, 2, true)
|
||||
};
|
||||
}
|
||||
|
|
@ -1,32 +1,36 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.api.Lib;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import malte0811.industrialwires.client.ClientUtilsIW;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.controlpanel.PropertyComponents.PanelRenderProperties;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
|
||||
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.panelmodel.SmartLightingQuadIW;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents.PanelRenderProperties;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
|
@ -38,7 +42,9 @@ import net.minecraft.nbt.NBTTagFloat;
|
|||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
|
@ -50,8 +56,10 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
import static malte0811.industrialWires.controlpanel.PanelComponent.*;
|
||||
import static malte0811.industrialWires.util.MiscUtils.discoverLocal;
|
||||
|
||||
public final class PanelUtils {
|
||||
public static TextureAtlasSprite PANEL_TEXTURE;
|
||||
|
@ -64,16 +72,8 @@ public final class PanelUtils {
|
|||
@SideOnly(Side.CLIENT)
|
||||
public static List<BakedQuad> generateQuads(PanelRenderProperties components) {
|
||||
if (PANEL_TEXTURE == null) {
|
||||
TextureMap texMap = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
PANEL_TEXTURE = texMap.getAtlasSprite(IndustrialWires.MODID + ":blocks/control_panel");
|
||||
PANEL_TEXTURE = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(IndustrialWires.MODID + ":blocks/control_panel");
|
||||
}
|
||||
ItemStack source = components.getTextureSource();
|
||||
IBakedModel texModel = null;
|
||||
if (IndustrialWires.proxy.isValidTextureSource(source)) {
|
||||
texModel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(source,
|
||||
null, null);
|
||||
}
|
||||
final TextureAtlasSprite mainTex = texModel != null ? texModel.getParticleTexture() : PANEL_TEXTURE;
|
||||
List<BakedQuad> ret = new ArrayList<>();
|
||||
Matrix4 m4 = components.getPanelTopTransform();
|
||||
Matrix4 m4RotOnly = m4.copy();
|
||||
|
@ -86,7 +86,7 @@ public final class PanelUtils {
|
|||
Matrix4 m4Here = m4.copy().translate(pc.getX(), PanelComponent.Y_DELTA, pc.getY());
|
||||
List<RawQuad> compQuads = pc.getQuads();
|
||||
for (RawQuad bq : compQuads) {
|
||||
ret.add(ClientUtilsIW.bakeQuad(bq, m4Here, m4RotOnly));
|
||||
ret.add(bakeQuad(bq, m4Here, m4RotOnly));
|
||||
}
|
||||
}
|
||||
Matrix4 baseTrans = components.getPanelBaseTransform();
|
||||
|
@ -115,40 +115,61 @@ public final class PanelUtils {
|
|||
//TOP
|
||||
rawOut.add(new RawQuad(new Vector3f(xMin, height0, zMin), new Vector3f(xMin, height1, zMax),
|
||||
new Vector3f(xMax, height1, zMax), new Vector3f(xMax, height0, zMin),
|
||||
EnumFacing.UP, mainTex, WHITE, null, new float[]{0, 0, uMaxX, uMaxZ}, -1));
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, uMaxX, uMaxZ}, -1));
|
||||
//BOTTOM
|
||||
rawOut.add(new RawQuad(new Vector3f(xMin, 0, zMin), new Vector3f(xMax, 0, zMin),
|
||||
new Vector3f(xMax, 0, zMax), new Vector3f(xMin, 0, zMax),
|
||||
EnumFacing.DOWN, mainTex, WHITE, null, UV_FULL, -1));
|
||||
EnumFacing.DOWN, PANEL_TEXTURE, WHITE, null, UV_FULL, -1));
|
||||
//LEFT
|
||||
rawOut.add(new RawQuad(new Vector3f(xMin, 0, zMin), new Vector3f(xMin, 0, zMax),
|
||||
new Vector3f(xMin, height1, zMax), new Vector3f(xMin, height0, zMin),
|
||||
EnumFacing.UP, mainTex, WHITE, null, new float[][]{
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
|
||||
{0, 0}, {0, uMaxZ},
|
||||
{vMax1, uMaxZ}, {vMax0, 0}
|
||||
}, -1));
|
||||
//RIGHT
|
||||
rawOut.add(new RawQuad(new Vector3f(xMax, 0, zMin), new Vector3f(xMax, height0, zMin),
|
||||
new Vector3f(xMax, height1, zMax), new Vector3f(xMax, 0, zMax),
|
||||
EnumFacing.UP, mainTex, WHITE, null, new float[][]{
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
|
||||
{0, 0}, {vMax0, 0},
|
||||
{vMax1, uMaxZ}, {0, uMaxZ}
|
||||
}, -1));
|
||||
//BACK
|
||||
rawOut.add(new RawQuad(new Vector3f(xMax, 0, zMin), new Vector3f(xMin, 0, zMin),
|
||||
new Vector3f(xMin, height0, zMin), new Vector3f(xMax, height0, zMin),
|
||||
EnumFacing.UP, mainTex, WHITE, null, new float[]{0, 0, vMax0, uMaxX}, -1));
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax0, uMaxX}, -1));
|
||||
//FRONT
|
||||
rawOut.add(new RawQuad(new Vector3f(xMin, 0, zMax), new Vector3f(xMax, 0, zMax),
|
||||
new Vector3f(xMax, height1, zMax), new Vector3f(xMin, height1, zMax),
|
||||
EnumFacing.UP, mainTex, WHITE, null, new float[]{0, 0, vMax1, uMaxX}, -1));
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax1, uMaxX}, -1));
|
||||
for (RawQuad bq : rawOut) {
|
||||
ret.add(ClientUtilsIW.bakeQuad(bq, baseTrans, baseNorm));
|
||||
ret.add(bakeQuad(bq, baseTrans, baseNorm));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static BakedQuad bakeQuad(RawQuad raw, Matrix4 transform, Matrix4 transfNormal) {
|
||||
VertexFormat format = DefaultVertexFormats.ITEM;
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
|
||||
builder.setQuadOrientation(raw.facing);
|
||||
builder.setTexture(raw.tex);
|
||||
Vector3f[] vertices = raw.vertices;
|
||||
float[][] uvs = raw.uvs;
|
||||
Vector3f normal = transfNormal.apply(raw.normal);
|
||||
OBJModel.Normal faceNormal = new OBJModel.Normal(normal.x, normal.y, normal.z);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
putVertexData(format, builder, transform.apply(vertices[i]), faceNormal, uvs[i][0], uvs[i][1], raw.tex,
|
||||
raw.colorA);
|
||||
}
|
||||
BakedQuad ret = builder.build();
|
||||
if (raw.light>0) {
|
||||
ret = new SmartLightingQuadIW(ret, raw.light);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//mostly copied from IE's ClientUtils, it has protected access there...
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void putVertexData(VertexFormat format, UnpackedBakedQuad.Builder builder, Vector3f pos, OBJModel.Normal faceNormal, double u, double v, TextureAtlasSprite sprite, float[] colorA) {
|
||||
|
@ -254,7 +275,6 @@ public final class PanelUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void addInfo(ItemStack stack, List<String> list, NBTTagCompound data) {
|
||||
switch (stack.getMetadata()) {
|
||||
case 0: //button
|
||||
|
@ -280,6 +300,7 @@ public final class PanelUtils {
|
|||
if (data.hasKey(LENGTH)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.length", data.getFloat(LENGTH)));
|
||||
}
|
||||
|
||||
break;
|
||||
case 4://variac
|
||||
addCommonInfo(data, list, false, true);
|
||||
|
@ -298,14 +319,15 @@ public final class PanelUtils {
|
|||
break;
|
||||
case 8://Panel meter
|
||||
addCommonInfo(data, list, false, true);
|
||||
if (data.hasKey(WIDE)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(WIDE) ? "wide" : "narrow")));
|
||||
if (data.hasKey(PanelMeter.WIDE)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(PanelMeter.WIDE) ? "wide" : "narrow")));
|
||||
}
|
||||
break;
|
||||
case 9://7-digit display
|
||||
addCommonInfo(data, list, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void addCommonInfo(NBTTagCompound data, List<String> list, boolean color, boolean rs) {
|
||||
if (color && data.hasKey(COLOR)) {
|
||||
String hexCol = String.format("%6s", Integer.toHexString(data.getInteger(COLOR) & 0xffffff)).replace(' ', '0');
|
||||
|
@ -314,7 +336,7 @@ public final class PanelUtils {
|
|||
if (rs && data.hasKey(RS_CHANNEL)) {
|
||||
EnumDyeColor channColor = EnumDyeColor.byMetadata(data.getInteger(RS_CHANNEL));
|
||||
String hexCol = Integer.toHexString(channColor.getColorValue());
|
||||
list.add(I18n.format("desc.immersiveengineering.info.redstoneChannel", "<hexcol=" + hexCol + ":" + channColor.getTranslationKey() + ">"));
|
||||
list.add(I18n.format("desc.immersiveengineering.info.redstoneChannel", "<hexcol=" + hexCol + ":" + channColor.getUnlocalizedName() + ">"));
|
||||
}
|
||||
if (rs && data.hasKey(RS_ID)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.rsId", data.getInteger(RS_ID)));
|
||||
|
@ -371,6 +393,27 @@ public final class PanelUtils {
|
|||
return panelBase;
|
||||
}
|
||||
|
||||
public static List<BlockPos> discoverPanelParts(World w, BlockPos here, int maxCount) {
|
||||
BiPredicate<BlockPos, Integer> isValid = (pos, count) -> {
|
||||
if (pos.equals(here)) {
|
||||
return true;
|
||||
}
|
||||
if (here.distanceSq(pos) > 25 || count > maxCount || !w.isBlockLoaded(pos)) {
|
||||
return false;
|
||||
}
|
||||
IBlockState state = w.getBlockState(pos);
|
||||
return state.getBlock() == IndustrialWires.panel && state.getValue(BlockPanel.type).isPanelConnector();
|
||||
};
|
||||
List<BlockPos> all = discoverLocal(w, here, isValid);
|
||||
List<BlockPos> ret = new ArrayList<>();
|
||||
for (BlockPos pos : all) {
|
||||
if (w.getBlockState(pos).getBlock() == IndustrialWires.panel && w.getBlockState(pos).getValue(BlockPanel.type) != BlockTypes_Panel.DUMMY) {
|
||||
ret.add(pos);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static float getAngle(ItemStack inv) {
|
||||
float angle = 0;
|
||||
NBTTagCompound nbt = inv.getTagCompound();
|
|
@ -1,28 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -66,7 +65,6 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
private Matrix4 topTransform;
|
||||
private Matrix4 topTransformInverse;
|
||||
private Matrix4 baseTransform;
|
||||
private ItemStack textureSource = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.DUMMY.ordinal());
|
||||
|
||||
|
||||
public PanelRenderProperties() {
|
||||
|
@ -179,8 +177,6 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
ret.facing = facing;
|
||||
ret.top = top;
|
||||
ret.angle = angle;
|
||||
ret.height = height;
|
||||
ret.textureSource = textureSource;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -205,14 +201,6 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
}
|
||||
}
|
||||
|
||||
public void setTextureSource(ItemStack textureSource) {
|
||||
if (textureSource.getItem() instanceof ItemBlock)
|
||||
this.textureSource = textureSource;
|
||||
}
|
||||
|
||||
public ItemStack getTextureSource() {
|
||||
return textureSource;
|
||||
}
|
||||
|
||||
public float getHeight() {
|
||||
return height;
|
||||
|
@ -258,8 +246,7 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
if (Float.compare(that.height, height) != 0) return false;
|
||||
if (Float.compare(that.angle, angle) != 0) return false;
|
||||
if (facing != that.facing) return false;
|
||||
if (top != that.top) return false;
|
||||
return ItemStack.areItemStacksEqual(textureSource, that.textureSource);
|
||||
return top == that.top;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
|
@ -13,18 +13,19 @@
|
|||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannelState;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
|
@ -39,8 +40,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialwires.util.MiscUtils.*;
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
import static malte0811.industrialWires.util.MiscUtils.*;
|
||||
|
||||
public class SevenSegDisplay extends PanelComponent implements IConfigurableComponent {
|
||||
public static final String NAME = "7seg";
|
||||
|
@ -83,23 +83,24 @@ public class SevenSegDisplay extends PanelComponent implements IConfigurableComp
|
|||
|
||||
private int color = 0xff00;
|
||||
private byte input = 0;
|
||||
@Nonnull
|
||||
private RSChannel inputChannel = RSChannel.DEFAULT_CHANNEL;
|
||||
private int rsInputId;
|
||||
private byte rsInputChannel;
|
||||
|
||||
public SevenSegDisplay() {
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
public SevenSegDisplay(@Nonnull RSChannel in, int color) {
|
||||
public SevenSegDisplay(int rsId, byte rsChannel, int color) {
|
||||
this();
|
||||
this.color = color;
|
||||
inputChannel = in;
|
||||
rsInputChannel = rsChannel;
|
||||
rsInputId = rsId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
|
||||
nbt.setInteger(RS_ID, inputChannel.getController());
|
||||
nbt.setByte(RS_CHANNEL, inputChannel.getColor());
|
||||
nbt.setInteger(RS_ID, rsInputId);
|
||||
nbt.setByte(RS_CHANNEL, rsInputChannel);
|
||||
nbt.setInteger(COLOR, color);
|
||||
if (!toItem) {
|
||||
nbt.setInteger("rsInput", input);
|
||||
|
@ -108,25 +109,29 @@ public class SevenSegDisplay extends PanelComponent implements IConfigurableComp
|
|||
|
||||
@Override
|
||||
protected void readCustomNBT(NBTTagCompound nbt) {
|
||||
int rsController = nbt.getInteger(RS_ID);
|
||||
byte rsColor = nbt.getByte(RS_CHANNEL);
|
||||
inputChannel = new RSChannel(rsController, rsColor);
|
||||
rsInputId = nbt.getInteger(RS_ID);
|
||||
rsInputChannel = nbt.getByte(RS_CHANNEL);
|
||||
color = nbt.getInteger(COLOR);
|
||||
input = nbt.getByte("rsInput");
|
||||
}
|
||||
|
||||
private TileEntityPanel panel;
|
||||
private Consumer<byte[]> handler = (inputNew) -> {
|
||||
if (inputNew[rsInputChannel] != input) {
|
||||
input = inputNew[rsInputChannel];
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void setNetwork(ControlPanelNetwork net) {
|
||||
super.setNetwork(net);
|
||||
Consumer<RSChannelState> handler = (inputNew) -> {
|
||||
if (inputNew.getStrength() != input) {
|
||||
input = inputNew.getStrength();
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
}
|
||||
};
|
||||
net.addListener(this, handler, inputChannel);
|
||||
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
|
||||
if (matchesId(rsInputId, id)) {
|
||||
this.panel = panel;
|
||||
return handler;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -181,7 +186,7 @@ public class SevenSegDisplay extends PanelComponent implements IConfigurableComp
|
|||
@Nonnull
|
||||
@Override
|
||||
public PanelComponent copyOf() {
|
||||
SevenSegDisplay ret = new SevenSegDisplay(inputChannel, color);
|
||||
SevenSegDisplay ret = new SevenSegDisplay(rsInputId, rsInputChannel, color);
|
||||
ret.input = input;
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
|
@ -198,12 +203,12 @@ public class SevenSegDisplay extends PanelComponent implements IConfigurableComp
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRelative, EntityPlayerMP player) {
|
||||
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
//NOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update(TileEntityPanel tile) {
|
||||
//NOP
|
||||
}
|
||||
|
||||
|
@ -238,10 +243,10 @@ public class SevenSegDisplay extends PanelComponent implements IConfigurableComp
|
|||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
inputChannel = inputChannel.withColor(value);
|
||||
rsInputChannel = ((NBTTagByte) value).getByte();
|
||||
break;
|
||||
case INT:
|
||||
inputChannel = inputChannel.withController(value);
|
||||
rsInputId = ((NBTTagInt) value).getInt();
|
||||
break;
|
||||
case FLOAT:
|
||||
color = PanelUtils.setColor(color, id, value);
|
||||
|
@ -251,7 +256,6 @@ public class SevenSegDisplay extends PanelComponent implements IConfigurableComp
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
|
@ -265,7 +269,6 @@ public class SevenSegDisplay extends PanelComponent implements IConfigurableComp
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
|
@ -280,16 +283,16 @@ public class SevenSegDisplay extends PanelComponent implements IConfigurableComp
|
|||
}
|
||||
|
||||
@Override
|
||||
public RSColorConfig[] getRSChannelOptions() {
|
||||
return new RSColorConfig[]{
|
||||
new RSColorConfig("channel", 0, 0, inputChannel.getColor())
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{
|
||||
new RSChannelConfig("channel", 0, 0, rsInputChannel)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{
|
||||
new IntConfig("rsId", 0, 45, inputChannel.getController(), 2, false)
|
||||
new IntConfig("rsId", 0, 45, rsInputId, 2, false)
|
||||
};
|
||||
}
|
||||
|
|
@ -1,32 +1,32 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannelState;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.util.TriConsumer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagFloat;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -36,9 +36,9 @@ import org.lwjgl.util.vector.Vector3f;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
import java.util.Set;
|
||||
|
||||
public class Slider extends PanelComponent implements IConfigurableComponent {
|
||||
private static final float WIDTH = .0625F;
|
||||
|
@ -46,18 +46,23 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
private int color = 0xffff00;
|
||||
private boolean horizontal;
|
||||
private int out;
|
||||
@Nonnull
|
||||
private RSChannel primary = RSChannel.DEFAULT_CHANNEL;
|
||||
@Nonnull
|
||||
private RSChannel secondary = RSChannel.INVALID_CHANNEL;
|
||||
private byte rsChannel;
|
||||
private int rsId;
|
||||
private boolean hasSecond;
|
||||
private byte rsChannel2;
|
||||
private int rsId2 = -1;
|
||||
private Set<TriConsumer<Integer, Byte, PanelComponent>> secOutputs = new HashSet<>();
|
||||
|
||||
public Slider(float length, int color, boolean horizontal, @Nonnull RSChannel primary, @Nonnull RSChannel secondary) {
|
||||
public Slider(float length, int color, boolean horizontal, int rsId, byte rsChannel, boolean hasSecond, int rsId2, byte rsChannel2) {
|
||||
this();
|
||||
this.color = color;
|
||||
this.length = length;
|
||||
this.horizontal = horizontal;
|
||||
this.primary = primary;
|
||||
this.secondary = secondary;
|
||||
this.rsChannel = rsChannel;
|
||||
this.rsId = rsId;
|
||||
this.hasSecond = hasSecond;
|
||||
this.rsChannel2 = rsChannel2;
|
||||
this.rsId2 = rsId2;
|
||||
}
|
||||
|
||||
public Slider() {
|
||||
|
@ -71,10 +76,10 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
if (!toItem) {
|
||||
nbt.setInteger("output", out);
|
||||
}
|
||||
nbt.setInteger(RS_ID, primary.getController());
|
||||
nbt.setByte(RS_CHANNEL, primary.getColor());
|
||||
nbt.setInteger(RS_ID2, secondary.getController());
|
||||
nbt.setByte(RS_CHANNEL2, secondary.getColor());
|
||||
nbt.setByte(RS_CHANNEL, rsChannel);
|
||||
nbt.setInteger(RS_ID, rsId);
|
||||
nbt.setByte(RS_CHANNEL2, rsChannel2);
|
||||
nbt.setInteger(RS_ID2, rsId2);
|
||||
nbt.setBoolean(HORIZONTAL, horizontal);
|
||||
}
|
||||
|
||||
|
@ -84,15 +89,14 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
length = nbt.getFloat(LENGTH);
|
||||
horizontal = nbt.getBoolean(HORIZONTAL);
|
||||
out = nbt.getInteger("output");
|
||||
int rsController = nbt.getInteger(RS_ID);
|
||||
byte rsColor = nbt.getByte(RS_CHANNEL);
|
||||
primary = new RSChannel(rsController, rsColor);
|
||||
if (nbt.hasKey(RS_ID2)) {
|
||||
rsController = nbt.getInteger(RS_ID2);
|
||||
rsColor = nbt.getByte(RS_CHANNEL2);
|
||||
secondary = new RSChannel(rsController, rsColor);
|
||||
} else {
|
||||
secondary = RSChannel.INVALID_CHANNEL;
|
||||
rsChannel = nbt.getByte(RS_CHANNEL);
|
||||
rsId = nbt.getInteger(RS_ID);
|
||||
rsChannel2 = nbt.getByte(RS_CHANNEL2);
|
||||
rsId2 = nbt.getInteger(RS_ID2);
|
||||
hasSecond = rsId2>=0&&rsChannel2>=0;
|
||||
if (!hasSecond) {
|
||||
rsChannel2 = -1;
|
||||
rsId2 = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +130,7 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
@Nonnull
|
||||
@Override
|
||||
public PanelComponent copyOf() {
|
||||
Slider ret = new Slider(length, color, horizontal, primary, secondary);
|
||||
Slider ret = new Slider(length, color, horizontal, rsId, rsChannel, hasSecond, rsId2, rsChannel2);
|
||||
ret.out = out;
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
|
@ -144,24 +148,38 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRelative, EntityPlayerMP player) {
|
||||
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
double pos = horizontal ? hitRelative.x : (length - hitRelative.z);
|
||||
int newLevel = (int) Math.min(pos * 256 / length, 255);
|
||||
if (newLevel != out) {
|
||||
setOut(newLevel);
|
||||
out = newLevel;
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (matchesId(rsId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept((int) rsChannel, (byte) (this.out>>4), this);
|
||||
}
|
||||
if (matchesId(rsId2, id)) {
|
||||
secOutputs.add(out);
|
||||
out.accept((int) rsChannel, (byte) (this.out&0xf), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(ControlPanelNetwork net) {
|
||||
super.setNetwork(net);
|
||||
network.setOutputs(this, new RSChannelState(primary, (byte) (out>>4)));
|
||||
network.setOutputs(this, new RSChannelState(secondary, (byte) (out&0xf)));
|
||||
public void unregisterRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
super.unregisterRSOutput(id, out);
|
||||
secOutputs.remove(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(TileEntityPanel tile) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -182,12 +200,18 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
Gui.drawRect(left, top, right, bottom, 0xff000000 | color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
setOut(0);
|
||||
}
|
||||
|
||||
public void setOut(int value) {
|
||||
network.setOutputs(this, new RSChannelState(primary, (byte) (value>>4)));
|
||||
network.setOutputs(this, new RSChannelState(secondary, (byte) (value&0xf)));
|
||||
out = value;
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
super.setOut(rsChannel, value>>4);
|
||||
if (hasSecond) {
|
||||
for (TriConsumer<Integer, Byte, PanelComponent> cons:secOutputs) {
|
||||
cons.accept((int) rsChannel2, (byte) (value&0xf), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,8 +226,11 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
if (color != slider.color) return false;
|
||||
if (horizontal != slider.horizontal) return false;
|
||||
if (out != slider.out) return false;
|
||||
if (!primary.equals(slider.primary)) return false;
|
||||
return secondary.equals(slider.secondary);
|
||||
if (rsChannel != slider.rsChannel) return false;
|
||||
if (rsId != slider.rsId) return false;
|
||||
if (hasSecond != slider.hasSecond) return false;
|
||||
if (rsChannel2 != slider.rsChannel2) return false;
|
||||
return rsId2 == slider.rsId2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -213,38 +240,42 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
result = 31 * result + color;
|
||||
result = 31 * result + (horizontal ? 1 : 0);
|
||||
result = 31 * result + out;
|
||||
result = 31 * result + primary.hashCode();
|
||||
result = 31 * result + secondary.hashCode();
|
||||
result = 31 * result + (int) rsChannel;
|
||||
result = 31 * result + rsId;
|
||||
result = 31 * result + (hasSecond ? 1 : 0);
|
||||
result = 31 * result + (int) rsChannel2;
|
||||
result = 31 * result + rsId2;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
horizontal = ((NBTTagByte) value).getByte() != 0;
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id == 0) {
|
||||
primary = primary.withColor(value);
|
||||
} else {
|
||||
secondary = secondary.withColor(value);
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id == 0) {
|
||||
primary = primary.withController(value);
|
||||
} else {
|
||||
secondary = secondary.withController(value);
|
||||
}
|
||||
break;
|
||||
case FLOAT:
|
||||
if (id < 3) {
|
||||
color = PanelUtils.setColor(color, id, value);
|
||||
} else {
|
||||
length = scaleToRangePercent(((NBTTagFloat) value).getFloat(), .125F, 1);
|
||||
}
|
||||
break;
|
||||
case BOOL:
|
||||
horizontal = ((NBTTagByte) value).getByte() != 0;
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id==0) {
|
||||
rsChannel = ((NBTTagByte) value).getByte();
|
||||
} else {
|
||||
rsChannel2 = ((NBTTagByte) value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id==0) {
|
||||
rsId = ((NBTTagInt) value).getInt();
|
||||
} else {
|
||||
rsId2 = ((NBTTagInt) value).getInt();
|
||||
hasSecond = rsId2>=0;
|
||||
}
|
||||
break;
|
||||
case FLOAT:
|
||||
if (id < 3) {
|
||||
color = PanelUtils.setColor(color, id, value);
|
||||
} else {
|
||||
length = scaleToRangePercent(((NBTTagFloat) value).getFloat(), .125F, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +284,6 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
|
@ -269,7 +299,6 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
|
@ -286,25 +315,25 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RSColorConfig[] getRSChannelOptions() {
|
||||
return new RSColorConfig[]{
|
||||
new RSColorConfig("channel", 0, 0, primary.getColor(), true),
|
||||
new RSColorConfig("channel2", 30, 0, secondary.getColor(), true)
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{
|
||||
new RSChannelConfig("channel", 0, 0, rsChannel, true),
|
||||
new RSChannelConfig("channel", 30, 0, rsChannel2, true)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{
|
||||
new IntConfig("rsId", 0, 30, primary.getController(), 2, false),
|
||||
new IntConfig("rsId2", 30, 30, secondary.getController(), 2, true)
|
||||
new IntConfig("rsId", 0, 30, rsId, 2, false),
|
||||
new IntConfig("rsId", 30, 30, rsId2, 2, true)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoolConfig[] getBooleanOptions() {
|
||||
return new BoolConfig[]{
|
||||
new BoolConfig("horizontal", 0, 40, horizontal)
|
||||
new BoolConfig("horizontal", 0, 70, horizontal)
|
||||
};
|
||||
}
|
||||
|
|
@ -1,31 +1,36 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannelState;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.util.TriConsumer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -37,26 +42,24 @@ import javax.annotation.Nonnull;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.RS_CHANNEL;
|
||||
import static malte0811.industrialwires.util.NBTKeys.RS_ID;
|
||||
|
||||
public class ToggleSwitch extends PanelComponent implements IConfigurableComponent {
|
||||
protected boolean active;
|
||||
@Nonnull
|
||||
protected RSChannel outputChannel = RSChannel.DEFAULT_CHANNEL;
|
||||
public boolean active;
|
||||
public int rsOutputId;
|
||||
public byte rsOutputChannel;
|
||||
|
||||
public ToggleSwitch() {
|
||||
super("toggle_switch");
|
||||
}
|
||||
|
||||
protected ToggleSwitch(String name) {
|
||||
public ToggleSwitch(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public ToggleSwitch(boolean active, @Nonnull RSChannel outputChannel) {
|
||||
public ToggleSwitch(boolean active, int rsOutputId, byte rsOutputChannel) {
|
||||
this();
|
||||
this.active = active;
|
||||
this.outputChannel = outputChannel;
|
||||
this.rsOutputChannel = rsOutputChannel;
|
||||
this.rsOutputId = rsOutputId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,22 +67,15 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
if (!toItem) {
|
||||
nbt.setBoolean("active", active);
|
||||
}
|
||||
nbt.setByte(RS_CHANNEL, outputChannel.getColor());
|
||||
nbt.setInteger(RS_ID, outputChannel.getController());
|
||||
nbt.setByte(RS_CHANNEL, rsOutputChannel);
|
||||
nbt.setInteger(RS_ID, rsOutputId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readCustomNBT(NBTTagCompound nbt) {
|
||||
active = nbt.getBoolean("active");
|
||||
int rsController = nbt.getInteger(RS_ID);
|
||||
byte rsColor = nbt.getByte(RS_CHANNEL);
|
||||
outputChannel = new RSChannel(rsController, rsColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(ControlPanelNetwork net) {
|
||||
super.setNetwork(net);
|
||||
network.setOutputs(this, new RSChannelState(outputChannel, (byte) (active ? 15 : 0)));
|
||||
rsOutputChannel = nbt.getByte(RS_CHANNEL);
|
||||
rsOutputId = nbt.getInteger(RS_ID);
|
||||
}
|
||||
|
||||
protected float sizeX = .0625F;
|
||||
|
@ -106,7 +102,7 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
@Override
|
||||
@Nonnull
|
||||
public PanelComponent copyOf() {
|
||||
ToggleSwitch ret = new ToggleSwitch(active, outputChannel);
|
||||
ToggleSwitch ret = new ToggleSwitch(active, rsOutputId, rsOutputChannel);
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.panelHeight = panelHeight;
|
||||
|
@ -123,15 +119,25 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRel, EntityPlayerMP player) {
|
||||
setOut(!active);
|
||||
public void interactWith(Vec3d hitRel, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
setOut(!active, tile);
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update(TileEntityPanel tile) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (matchesId(rsOutputId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept((int) rsOutputChannel, (byte) (active ? 15 : 0), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return .0625F * 3 / 2;
|
||||
|
@ -156,11 +162,16 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
|
||||
}
|
||||
|
||||
protected void setOut(boolean on) {
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
setOut(rsOutputChannel, 0);
|
||||
}
|
||||
|
||||
protected void setOut(boolean on, TileEntityPanel tile) {
|
||||
active = on;
|
||||
network.setOutputs(this, new RSChannelState(outputChannel, (byte) (active ? 15 : 0)));
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
setOut(rsOutputChannel, active ? 15 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -172,22 +183,16 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
ToggleSwitch that = (ToggleSwitch) o;
|
||||
|
||||
if (active != that.active) return false;
|
||||
if (Float.compare(that.sizeX, sizeX) != 0) return false;
|
||||
if (Float.compare(that.sizeY, sizeY) != 0) return false;
|
||||
if (Float.compare(that.rodRadius, rodRadius) != 0) return false;
|
||||
if (Float.compare(that.rodLength, rodLength) != 0) return false;
|
||||
return outputChannel.equals(that.outputChannel);
|
||||
if (rsOutputId != that.rsOutputId) return false;
|
||||
return rsOutputChannel == that.rsOutputChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (active ? 1 : 0);
|
||||
result = 31 * result + outputChannel.hashCode();
|
||||
result = 31 * result + (sizeX != +0.0f ? Float.floatToIntBits(sizeX) : 0);
|
||||
result = 31 * result + (sizeY != +0.0f ? Float.floatToIntBits(sizeY) : 0);
|
||||
result = 31 * result + (rodRadius != +0.0f ? Float.floatToIntBits(rodRadius) : 0);
|
||||
result = 31 * result + (rodLength != +0.0f ? Float.floatToIntBits(rodLength) : 0);
|
||||
result = 31 * result + rsOutputId;
|
||||
result = 31 * result + (int) rsOutputChannel;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -195,16 +200,19 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
outputChannel = outputChannel.withColor(value);
|
||||
if (id == 0) {
|
||||
rsOutputChannel = ((NBTTagByte) value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
outputChannel = outputChannel.withController(value);
|
||||
if (id == 0) {
|
||||
rsOutputId = ((NBTTagInt) value).getInt();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
|
@ -218,7 +226,6 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
|
@ -233,13 +240,13 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
}
|
||||
|
||||
@Override
|
||||
public RSColorConfig[] getRSChannelOptions() {
|
||||
return new RSColorConfig[]{new RSColorConfig("channel", 0, 0, outputChannel.getColor())};
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{new RSChannelConfig("channel", 0, 0, (byte) rsOutputChannel)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{new IntConfig("rsId", 0, 50, outputChannel.getController(), 2, false)};
|
||||
return new IntConfig[]{new IntConfig("rsId", 0, 50, rsOutputId, 2, false)};
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,32 +1,37 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.controlpanel;
|
||||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannelState;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.util.TriConsumer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -36,9 +41,9 @@ import org.lwjgl.util.vector.Vector3f;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
import java.util.Set;
|
||||
|
||||
public class Variac extends PanelComponent implements IConfigurableComponent {
|
||||
private static final float SIZE = 3 / 16F;
|
||||
|
@ -51,15 +56,20 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
private static final float arrowSize = .0625F / 2;
|
||||
|
||||
private int out;
|
||||
@Nonnull
|
||||
private RSChannel primary = RSChannel.DEFAULT_CHANNEL;
|
||||
@Nonnull
|
||||
private RSChannel secondary = RSChannel.INVALID_CHANNEL;
|
||||
private byte rsChannel;
|
||||
private int rsId;
|
||||
private boolean hasSecond;
|
||||
private byte rsChannel2;
|
||||
private int rsId2 = -1;
|
||||
private Set<TriConsumer<Integer, Byte, PanelComponent>> secOutputs = new HashSet<>();
|
||||
|
||||
public Variac(@Nonnull RSChannel primary, @Nonnull RSChannel secondary) {
|
||||
public Variac(int rsId, byte rsChannel, int rsId2, byte rsChannel2, boolean hasSecond) {
|
||||
this();
|
||||
this.primary = primary;
|
||||
this.secondary = secondary;
|
||||
this.rsChannel = rsChannel;
|
||||
this.rsId = rsId;
|
||||
this.hasSecond = hasSecond;
|
||||
this.rsChannel2 = rsChannel2;
|
||||
this.rsId2 = rsId2;
|
||||
}
|
||||
|
||||
public Variac() {
|
||||
|
@ -71,24 +81,23 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
if (!toItem) {
|
||||
nbt.setInteger("output", out);
|
||||
}
|
||||
nbt.setInteger(RS_ID, primary.getController());
|
||||
nbt.setByte(RS_CHANNEL, primary.getColor());
|
||||
nbt.setInteger(RS_ID2, secondary.getController());
|
||||
nbt.setByte(RS_CHANNEL2, secondary.getColor());
|
||||
nbt.setByte(RS_CHANNEL, rsChannel);
|
||||
nbt.setInteger(RS_ID, rsId);
|
||||
nbt.setByte(RS_CHANNEL2, rsChannel2);
|
||||
nbt.setInteger(RS_ID2, rsId2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readCustomNBT(NBTTagCompound nbt) {
|
||||
out = nbt.getInteger("output");
|
||||
int rsController = nbt.getInteger(RS_ID);
|
||||
byte rsColor = nbt.getByte(RS_CHANNEL);
|
||||
primary = new RSChannel(rsController, rsColor);
|
||||
if (nbt.hasKey(RS_ID2)) {
|
||||
rsController = nbt.getInteger(RS_ID2);
|
||||
rsColor = nbt.getByte(RS_CHANNEL2);
|
||||
secondary = new RSChannel(rsController, rsColor);
|
||||
} else {
|
||||
secondary = RSChannel.INVALID_CHANNEL;
|
||||
rsChannel = nbt.getByte(RS_CHANNEL);
|
||||
rsId = nbt.getInteger(RS_ID);
|
||||
rsChannel2 = nbt.getByte(RS_CHANNEL2);
|
||||
rsId2 = nbt.getInteger(RS_ID2);
|
||||
hasSecond = rsChannel2>=0&&rsId2>=0;
|
||||
if (!hasSecond) {
|
||||
rsChannel2 = -1;
|
||||
rsId2 = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +131,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
@Nonnull
|
||||
@Override
|
||||
public PanelComponent copyOf() {
|
||||
Variac ret = new Variac(primary, secondary);
|
||||
Variac ret = new Variac(rsId, rsChannel, rsId2, rsChannel2, hasSecond);
|
||||
ret.out = out;
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
|
@ -140,7 +149,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRelative, EntityPlayerMP player) {
|
||||
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
double xRel = hitRelative.x - SIZE / 2;
|
||||
double yRel = -(hitRelative.z - SIZE / 2);
|
||||
double angle = 1.5 * Math.PI - Math.atan2(yRel, xRel);
|
||||
|
@ -150,7 +159,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
angle -= 2 * Math.PI;
|
||||
}
|
||||
angle /= 2 * Math.PI;
|
||||
int step = (secondary.isValid()&&player.isSneaking())?1:16;
|
||||
int step = (hasSecond&&player.isSneaking())?1:16;
|
||||
int newLevel = (int) ((angle-1/34F) * 17 * 16);
|
||||
int diff = Math.abs(newLevel-out);
|
||||
if (diff>step) {
|
||||
|
@ -163,19 +172,33 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
newLevel = Math.max(0, Math.min(newLevel, 255));
|
||||
if (newLevel != out) {
|
||||
setOut(newLevel);
|
||||
out = newLevel;
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (matchesId(rsId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept((int) rsChannel, (byte) (this.out>>4), this);
|
||||
}
|
||||
if (matchesId(rsId2, id)) {
|
||||
secOutputs.add(out);
|
||||
out.accept((int)rsChannel2, (byte) (this.out&0xf), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(ControlPanelNetwork net) {
|
||||
super.setNetwork(net);
|
||||
network.setOutputs(this, new RSChannelState(primary, (byte) (out>>4)));
|
||||
network.setOutputs(this, new RSChannelState(secondary, (byte) (out&0xf)));
|
||||
public void unregisterRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
super.unregisterRSOutput(id, out);
|
||||
secOutputs.remove(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(TileEntityPanel tile) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -193,23 +216,29 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
int bottom = (int) Math.floor(gui.getY0() + (aabb.maxZ - offset) * gui.panelSize);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((left + right) / 2F, (top + bottom) / 2F, 0);
|
||||
GlStateManager.translate((left + right) / 2, (top + bottom) / 2, 0);
|
||||
GlStateManager.rotate(360 / 17F, 0, 0, 1);
|
||||
GlStateManager.translate(-(left + right) / 2F, -(top + bottom) / 2F, 0);
|
||||
GlStateManager.translate(-(left + right) / 2, -(top + bottom) / 2, 0);
|
||||
Gui.drawRect(left, top, right, bottom, 0xff333333);
|
||||
GlStateManager.translate((left + right) / 2F, (top + bottom) / 2F, 0);
|
||||
GlStateManager.translate((left + right) / 2, (top + bottom) / 2, 0);
|
||||
GlStateManager.rotate(45, 0, 0, 1);
|
||||
GlStateManager.translate(-(left + right) / 2F, -(top + bottom) / 2F, 0);
|
||||
GlStateManager.translate(-(left + right) / 2, -(top + bottom) / 2, 0);
|
||||
Gui.drawRect(left, top, right, bottom, 0xff333333);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public void setOut(int value) {
|
||||
network.setOutputs(this, new RSChannelState(primary, (byte) (value>>4)));
|
||||
network.setOutputs(this, new RSChannelState(secondary, (byte) (value&0xf)));
|
||||
out = value;
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
setOut(0);
|
||||
}
|
||||
|
||||
public void setOut(int level) {
|
||||
if (hasSecond) {
|
||||
for (TriConsumer<Integer, Byte, PanelComponent> cons:secOutputs) {
|
||||
cons.accept((int)rsChannel2, (byte) (level&0xf), this);
|
||||
}
|
||||
}
|
||||
super.setOut(rsChannel, (byte)(level>>4));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -221,36 +250,43 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
Variac variac = (Variac) o;
|
||||
|
||||
if (out != variac.out) return false;
|
||||
if (!primary.equals(variac.primary)) return false;
|
||||
return secondary.equals(variac.secondary);
|
||||
if (rsChannel != variac.rsChannel) return false;
|
||||
if (rsId != variac.rsId) return false;
|
||||
if (hasSecond != variac.hasSecond) return false;
|
||||
if (rsChannel2 != variac.rsChannel2) return false;
|
||||
return rsId2 == variac.rsId2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + out;
|
||||
result = 31 * result + primary.hashCode();
|
||||
result = 31 * result + secondary.hashCode();
|
||||
result = 31 * result + (int) rsChannel;
|
||||
result = 31 * result + rsId;
|
||||
result = 31 * result + (hasSecond ? 1 : 0);
|
||||
result = 31 * result + (int) rsChannel2;
|
||||
result = 31 * result + rsId2;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyConfigOption(IConfigurableComponent.ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
if (id == 0) {
|
||||
primary = primary.withColor(value);
|
||||
} else {
|
||||
secondary = secondary.withColor(value);
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id == 0) {
|
||||
primary = primary.withController(value);
|
||||
} else {
|
||||
secondary = secondary.withController(value);
|
||||
}
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id==0) {
|
||||
rsChannel = ((NBTTagByte) value).getByte();
|
||||
} else {
|
||||
rsChannel2 = ((NBTTagByte) value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id==0) {
|
||||
rsId = ((NBTTagInt) value).getInt();
|
||||
} else {
|
||||
rsId2 = ((NBTTagInt) value).getInt();
|
||||
hasSecond = rsId2>=0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +296,6 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String fomatConfigDescription(IConfigurableComponent.ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
|
@ -273,18 +308,18 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RSColorConfig[] getRSChannelOptions() {
|
||||
return new RSColorConfig[]{
|
||||
new RSColorConfig("channel", 0, 0, primary.getColor()),
|
||||
new RSColorConfig("channel2", 90, 0, secondary.getColor())
|
||||
public IConfigurableComponent.RSChannelConfig[] getRSChannelOptions() {
|
||||
return new IConfigurableComponent.RSChannelConfig[]{
|
||||
new IConfigurableComponent.RSChannelConfig("channel", 0, 0, rsChannel),
|
||||
new IConfigurableComponent.RSChannelConfig("channel", 90, 0, rsChannel2)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{
|
||||
new IntConfig("rsId", 0, 50, primary.getController(), 2, false),
|
||||
new IntConfig("rsId2", 90, 50, secondary.getController(), 2, true)
|
||||
public IConfigurableComponent.IntConfig[] getIntegerOptions() {
|
||||
return new IConfigurableComponent.IntConfig[]{
|
||||
new IConfigurableComponent.IntConfig("rsId", 0, 50, rsId, 2, false),
|
||||
new IConfigurableComponent.IntConfig("rsId", 90, 50, rsId2, 2, true)
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
package malte0811.industrialWires.crafting;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.oredict.OreIngredient;
|
||||
import techreborn.api.TechRebornAPI;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
public final class IC2TRHelper {
|
||||
public static Ingredient getStack(String type, String variant) {
|
||||
Set<ItemStack> stacks = new HashSet<>();
|
||||
if (type.equals("crafting")&&variant.equals("rubber")) {
|
||||
if (ApiUtils.isExistingOreName("itemRubber")) {
|
||||
return new OreIngredient("itemRubber");
|
||||
}
|
||||
}
|
||||
if (IndustrialWires.hasIC2) {
|
||||
stacks.add(IC2Items.getItem(type, variant));
|
||||
}
|
||||
if (IndustrialWires.hasTechReborn) {
|
||||
switch (type) {
|
||||
case "cable":
|
||||
stacks.add(getTRCable(variant));
|
||||
break;
|
||||
case "crafting":
|
||||
switch (variant) {
|
||||
case "alloy":
|
||||
stacks.add(TechRebornAPI.subItemRetriever.getPlateByName("advanced_alloy"));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "te":
|
||||
if (variant.equals("mv_transformer")) {
|
||||
stacks.add(new ItemStack(TechRebornAPI.getBlock("MV_TRANSFORMER")));
|
||||
}
|
||||
}
|
||||
}
|
||||
stacks.removeIf(ItemStack::isEmpty);
|
||||
if (stacks.isEmpty()) {
|
||||
switch (type) {
|
||||
case "cable":
|
||||
return getIECable(variant.substring("type:".length(), variant.indexOf(',')));
|
||||
case "crafting":
|
||||
switch (variant) {
|
||||
case "coil":
|
||||
stacks.add(new ItemStack(IEContent.blockMetalDecoration0));
|
||||
break;
|
||||
case "alloy":
|
||||
return new OreIngredient("plateConstantan");
|
||||
case "electric_motor":
|
||||
stacks.add(new ItemStack(IEContent.itemMaterial, 1, 27));
|
||||
break;
|
||||
case "rubber":
|
||||
stacks.add(new ItemStack(IEContent.itemMaterial, 1, 13));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "te":
|
||||
if (variant.equals("mv_transformer")) {
|
||||
stacks.add(new ItemStack(IEContent.blockConnectors, 1, 7));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stacks.size()==0) {
|
||||
IndustrialWires.logger.info("No ingredient found for "+type+", "+variant);
|
||||
}
|
||||
return Ingredient.fromStacks(stacks.toArray(new ItemStack[stacks.size()]));
|
||||
}
|
||||
|
||||
public static ItemStack getTRCable(String variant) {
|
||||
String cableType = variant.substring("type:".length(), variant.indexOf(','));
|
||||
int meta = -1;
|
||||
switch (cableType) {
|
||||
case "copper":
|
||||
meta = 0;
|
||||
break;
|
||||
case "tin":
|
||||
meta = 1;
|
||||
break;
|
||||
case "glass":
|
||||
meta = 4;
|
||||
break;
|
||||
case "gold":
|
||||
meta = 2;
|
||||
break;
|
||||
case "iron":
|
||||
meta = 3;
|
||||
break;
|
||||
}
|
||||
if (meta>=0&&variant.charAt(variant.length()-1)=='0') {
|
||||
return new ItemStack(TechRebornAPI.getBlock("CABLE"), 1, meta);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
public static Ingredient getIECable(String type) {
|
||||
switch (type) {
|
||||
case "gold":
|
||||
type = "electrum";
|
||||
break;
|
||||
case "iron":
|
||||
type = "steel";
|
||||
break;
|
||||
case "tin":
|
||||
type = "aluminum";
|
||||
break;
|
||||
case "glass":
|
||||
throw new IllegalArgumentException(type+" is not a valid IE wire type");
|
||||
}
|
||||
type = Character.toUpperCase(type.charAt(0))+type.substring(1);
|
||||
return new OreIngredient("wire"+type);
|
||||
}
|
||||
}
|
|
@ -1,52 +1,55 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.crafting;
|
||||
package malte0811.industrialWires.crafting;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.IngredientNBT;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class RecipeCoilLength extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
public final ItemStack coil;
|
||||
public final List<Pair<Ingredient, Integer>> cables;
|
||||
public final Ingredient cable;
|
||||
private final int maxLength;
|
||||
|
||||
public RecipeCoilLength(ItemStack coil, List<Pair<Ingredient, Integer>> cables) {
|
||||
public RecipeCoilLength(ItemStack coil, Ingredient cable) {
|
||||
this.coil = coil;
|
||||
this.cables = cables;
|
||||
this.cable = cable;
|
||||
maxLength = ItemIC2Coil.getMaxWireLength(this.coil);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, @Nullable World worldIn) {
|
||||
int l = getLength(inv);
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, World worldIn) {
|
||||
int l = 0;//getLength(inv);
|
||||
return l > 0;
|
||||
}
|
||||
|
||||
|
@ -83,29 +86,26 @@ public class RecipeCoilLength extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
|||
ret.set(i, currStack);
|
||||
ItemIC2Coil.setLength(currStack, -length);
|
||||
}
|
||||
} else {
|
||||
length -= getCableLength(curr);
|
||||
} else if (isCable(curr)) {
|
||||
length--;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getLength(InventoryCrafting inv) {
|
||||
int totalLength = 0;
|
||||
int cableLength = 0;
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack curr = inv.getStackInSlot(i);
|
||||
if (OreDictionary.itemMatches(curr, coil, false)) {
|
||||
totalLength += ItemIC2Coil.getLength(curr);
|
||||
} else {
|
||||
int slotLength = getCableLength(curr);
|
||||
if (slotLength>0) {
|
||||
totalLength += slotLength;
|
||||
} else if (!curr.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
cableLength += ItemIC2Coil.getLength(curr);
|
||||
} else if (isCable(curr)) {
|
||||
cableLength++;
|
||||
} else if (!curr.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return totalLength;
|
||||
return cableLength;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -114,11 +114,8 @@ public class RecipeCoilLength extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
|||
Random r = new Random();
|
||||
NonNullList<Ingredient> ret = NonNullList.withSize(9, Ingredient.EMPTY);
|
||||
for (int i = 0;i<ret.size();i++) {
|
||||
int length = 1;
|
||||
for (Pair<Ingredient, Integer> cable:cables) {
|
||||
length += cable.getLeft().getMatchingStacks().length;
|
||||
}
|
||||
ItemStack[] types = new ItemStack[length];
|
||||
ItemStack[] types = new ItemStack[cable.getMatchingStacks().length+1];
|
||||
int length = types.length;
|
||||
int cablePos = 0;
|
||||
if (r.nextBoolean()) {
|
||||
types[length-1] = coil;
|
||||
|
@ -126,23 +123,19 @@ public class RecipeCoilLength extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
|||
types[0] = coil;
|
||||
cablePos = 1;
|
||||
}
|
||||
for (Pair<Ingredient, Integer> cable : cables) {
|
||||
ItemStack[] matching = cable.getLeft().getMatchingStacks();
|
||||
System.arraycopy(matching, 0, types, cablePos, matching.length);
|
||||
cablePos += matching.length;
|
||||
}
|
||||
System.arraycopy(cable.getMatchingStacks(), 0, types, cablePos, length-1);
|
||||
ret.set(i, new UnmatchedIngredient(types));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getCableLength(ItemStack stack) {
|
||||
for (Pair<Ingredient, Integer> ingred:cables) {
|
||||
if (ingred.getLeft().apply(stack)) {
|
||||
return ingred.getRight();
|
||||
private boolean isCable(ItemStack stack) {
|
||||
for (ItemStack curr:cable.getMatchingStacks()) {
|
||||
if (ItemStack.areItemsEqual(stack, curr) && ItemStack.areItemStackTagsEqual(stack, curr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
//There is probably a better way to do this...
|
|
@ -1,26 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.crafting;
|
||||
package malte0811.industrialWires.crafting;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import malte0811.industrialwires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialwires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
@ -33,31 +34,25 @@ import javax.annotation.Nullable;
|
|||
public class RecipeComponentCopy extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
|
||||
@Override
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, @Nullable World worldIn) {
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, World worldIn) {
|
||||
boolean found = false;
|
||||
int foundX = -1;
|
||||
int foundY = -1;
|
||||
boolean foundPanel;
|
||||
for (int x = 0; x < inv.getWidth(); x++) {
|
||||
for (int y = 0; y < inv.getHeight(); y++) {
|
||||
ItemStack here = inv.getStackInRowAndColumn(x, y);
|
||||
PanelComponent pc1 = ItemPanelComponent.componentFromStack(here);
|
||||
if (pc1 != null || isUnfinishedPanel(here)) {
|
||||
if (pc1!=null) {
|
||||
if (x==foundX&&y==foundY) {
|
||||
continue;
|
||||
}
|
||||
if (found) {
|
||||
return false;
|
||||
}
|
||||
foundPanel = pc1 == null;
|
||||
if (y+1<inv.getHeight()) {
|
||||
ItemStack below = inv.getStackInRowAndColumn(x, y + 1);
|
||||
PanelComponent pc2 = ItemPanelComponent.componentFromStack(below);
|
||||
if (foundPanel) {
|
||||
if (!isUnfinishedPanel(below)) {
|
||||
return false;
|
||||
}
|
||||
} else if (pc2 == null || pc2.getClass() != pc1.getClass()) {
|
||||
if (pc2 == null || pc2.getClass() != pc1.getClass()) {
|
||||
return false;
|
||||
}
|
||||
found = true;
|
||||
|
@ -105,8 +100,7 @@ public class RecipeComponentCopy extends IForgeRegistryEntry.Impl<IRecipe> imple
|
|||
for (int x = 0; x < inv.getWidth(); x++) {
|
||||
for (int y = 0; y < inv.getHeight() - 1; y++) {
|
||||
ItemStack here = inv.getStackInRowAndColumn(x, y);
|
||||
if (here.getItem() == IndustrialWires.panelComponent
|
||||
|| isUnfinishedPanel(here)) {
|
||||
if (!here.isEmpty() && here.getItem() == IndustrialWires.panelComponent) {
|
||||
return new int[]{x, y};
|
||||
}
|
||||
}
|
||||
|
@ -114,14 +108,8 @@ public class RecipeComponentCopy extends IForgeRegistryEntry.Impl<IRecipe> imple
|
|||
return null;
|
||||
}
|
||||
|
||||
private boolean isUnfinishedPanel(ItemStack stack) {
|
||||
return stack.getItem() == Item.getItemFromBlock(IndustrialWires.panel)
|
||||
&& stack.getMetadata() == BlockTypes_Panel.UNFINISHED.ordinal();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDynamic() {
|
||||
public boolean isHidden() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,24 +1,30 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.crafting;
|
||||
package malte0811.industrialWires.crafting;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper.ShapedPrimer;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
|
@ -1,25 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.crafting;
|
||||
package malte0811.industrialWires.crafting;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.controlpanel.Lock;
|
||||
import malte0811.industrialwires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialwires.items.ItemKey;
|
||||
import malte0811.industrialwires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.controlpanel.Lock;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.items.ItemKey;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
@ -29,12 +32,11 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class RecipeKeyLock extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
|
||||
@Override
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, @Nullable World worldIn) {
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, World worldIn) {
|
||||
return getLockId(inv) != 0;
|
||||
}
|
||||
|
|
@ -1,21 +1,24 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package malte0811.industrialwires.crafting;
|
||||
package malte0811.industrialWires.crafting;
|
||||
|
||||
import malte0811.industrialwires.IWConfig;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
@ -27,9 +30,8 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
import static malte0811.industrialWires.items.ItemKey.*;
|
||||
|
||||
public class RecipeKeyRing extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
|
||||
|
@ -39,7 +41,7 @@ public class RecipeKeyRing extends IForgeRegistryEntry.Impl<IRecipe> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, @Nullable World worldIn) {
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, World worldIn) {
|
||||
return isValid(inv);
|
||||
}
|
||||
|
|
@ -1,37 +1,39 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialwires.crafting;
|
||||
package malte0811.industrialWires.crafting;
|
||||
|
||||
import blusunrize.immersiveengineering.api.tool.AssemblerHandler;
|
||||
import ic2.api.item.IC2Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static malte0811.industrialwires.IndustrialWires.MODID;
|
||||
import static malte0811.industrialWires.IndustrialWires.MODID;
|
||||
|
||||
public class Recipes {
|
||||
public static void addRecipes(IForgeRegistry<IRecipe> registry) {
|
||||
registry.register(new RecipeKeyRing(true).setRegistryName(MODID, "add_key_ring"));
|
||||
registry.register(new RecipeKeyRing(false).setRegistryName(MODID, "remove_key_ring"));
|
||||
registry.register(new RecipeKeyLock().setRegistryName(MODID, "key_lock"));
|
||||
registry.register(new RecipePanelTexture().setRegistryName(MODID, "panel_texture"));
|
||||
registry.register(new RecipeComponentCopy().setRegistryName(MODID, "component_copy"));
|
||||
AssemblerHandler.registerRecipeAdapter(RecipeCoilLength.class, new Recipes.AllRecipeAdapter<>());
|
||||
AssemblerHandler.registerRecipeAdapter(RecipeComponentCopy.class, new Recipes.AllRecipeAdapter<>());
|
||||
|
@ -56,7 +58,7 @@ public class Recipes {
|
|||
ret.add(new AssemblerHandler.RecipeQuery(in.get(i), 1));
|
||||
}
|
||||
}
|
||||
return ret.toArray(new AssemblerHandler.RecipeQuery[0]);
|
||||
return ret.toArray(new AssemblerHandler.RecipeQuery[ret.size()]);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,29 @@
|
|||
package malte0811.industrialWires.crafting.factories;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.crafting.IC2TRHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraftforge.common.crafting.IIngredientFactory;
|
||||
import net.minecraftforge.common.crafting.IngredientNBT;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class IC2ItemFactory implements IIngredientFactory {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient parse(JsonContext context, JsonObject json) {
|
||||
String name = json.get("name").getAsString();
|
||||
String variant = json.get("variant").getAsString();
|
||||
return IC2TRHelper.getStack(name, variant);
|
||||
}
|
||||
//TODO NBT sensitivity?
|
||||
private class MyNBTIngredient extends IngredientNBT {
|
||||
|
||||
public MyNBTIngredient(ItemStack stack) {
|
||||
super(stack);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package malte0811.industrialWires.crafting.factories;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import malte0811.industrialWires.crafting.RecipeInitPC;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.common.crafting.IRecipeFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
public class InitPCFactory implements IRecipeFactory {
|
||||
@Override
|
||||
public IRecipe parse(JsonContext context, JsonObject json) {
|
||||
return new RecipeInitPC(ShapedOreRecipe.factory(context, json));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue