Compare commits
118 commits
Author | SHA1 | Date | |
---|---|---|---|
Timo Ley | 22ebc12fc8 | ||
Timo Ley | 7b056c057d | ||
Timo Ley | 041395b06e | ||
Timo Ley | 10eb55bc74 | ||
Timo Ley | 77b3fb454e | ||
9ea0b355a5 | |||
cf90f293a3 | |||
f9fe9de715 | |||
ba69040855 | |||
5aea1281ca | |||
507b5e11d8 | |||
86cefa9162 | |||
7c62332b57 | |||
0f3794e645 | |||
e9a8225f77 | |||
c6d2a26a6d | |||
63d9fca789 | |||
ceb28da474 | |||
c84a0476fd | |||
2f02fc5044 | |||
961b325111 | |||
c7045eb9a8 | |||
43bd502095 | |||
c433eb67b9 | |||
208fc0611e | |||
9fd6ec2d16 | |||
c5c1818749 | |||
88c10cdb81 | |||
a60b55cad1 | |||
93f156da4e | |||
51e139b568 | |||
9616e310a6 | |||
39ebc86029 | |||
69c8713853 | |||
cbcc95a010 | |||
a9a481c1cf | |||
8962cd1bcb | |||
0eb9a03185 | |||
d51562b937 | |||
c8bba65ad4 | |||
220b74ab94 | |||
1c24abda2c | |||
e00881400b | |||
f48d277280 | |||
d548bd5cf3 | |||
f228d2178d | |||
4fef9f6a04 | |||
7599b5cd31 | |||
fc2e9dca4d | |||
b5826d226b | |||
bd26b2b358 | |||
1cef97f260 | |||
c48bbb2d63 | |||
f94d73717f | |||
0a67837965 | |||
dca94087a2 | |||
cb7aef646a | |||
17598cc9e9 | |||
71716a722e | |||
16c01a8049 | |||
33cc33170e | |||
880d350720 | |||
40eaa907ef | |||
311a498a90 | |||
3d2865aa93 | |||
5364b14f5b | |||
375c30d139 | |||
e377b77819 | |||
2b9ec80253 | |||
7008f53faa | |||
63603d12f1 | |||
781ed3d773 | |||
bf8ea992b8 | |||
8c16f44970 | |||
0cda304c56 | |||
448489b01f | |||
7ebf25b3d5 | |||
b65cdc6fbe | |||
b3fefaa078 | |||
d5b537ea98 | |||
a756de6ace | |||
b43150d6c9 | |||
eb7f73464f | |||
3f08c47a73 | |||
b12501a86c | |||
1959b93f5b | |||
12510ecc5b | |||
bd0c941ac8 | |||
92a114d29d | |||
184d12b7cb | |||
b7bc55a0a9 | |||
87f4dc8f93 | |||
1fb01d9abd | |||
316cc2ab78 | |||
b913e28271 | |||
8cca1b13e1 | |||
56fb9e3b3a | |||
c3570a1273 | |||
23df4324ec | |||
8d98e30b04 | |||
b87b67b17f | |||
8190a4c80e | |||
129d8f732a | |||
d3508e42fe | |||
6c60b4562b | |||
ced4704b14 | |||
93fb75a0b0 | |||
ff3c391ac5 | |||
534f844d0e | |||
b09745a320 | |||
58692ceb76 | |||
b0156b70a0 | |||
8ff35f0ea4 | |||
37233621bf | |||
5b50013f68 | |||
15cf1010aa | |||
14fde279be | |||
afccf9b677 |
374
build.gradle
374
build.gradle
|
@ -1,123 +1,251 @@
|
|||
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'
|
||||
}
|
||||
}
|
||||
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
|
||||
|
|
51
changelog.json
Normal file
51
changelog.json
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"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,4 +1,81 @@
|
|||
#####Version 1.6-22
|
||||
###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
|
||||
- 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
|
||||
|
@ -6,14 +83,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
|
||||
|
@ -26,23 +103,32 @@
|
|||
- 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
|
||||
|
||||
#####Version 1.5-13
|
||||
###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
|
||||
- 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
|
||||
|
@ -50,36 +136,48 @@
|
|||
- 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
|
||||
|
||||
#####Version 1.4-10
|
||||
###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
|
||||
- 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
|
||||
|
@ -87,18 +185,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-3.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||
|
|
|
@ -1,228 +0,0 @@
|
|||
/*
|
||||
* 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,128 +0,0 @@
|
|||
/*
|
||||
* 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,394 +0,0 @@
|
|||
/*
|
||||
* 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,44 +0,0 @@
|
|||
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,58 +0,0 @@
|
|||
/*
|
||||
* 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));
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* 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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,412 +0,0 @@
|
|||
/*
|
||||
* 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,386 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
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,212 +0,0 @@
|
|||
/*
|
||||
* 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,66 +0,0 @@
|
|||
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,121 +0,0 @@
|
|||
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,29 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
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));
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package malte0811.industrialWires.crafting.factories;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import net.minecraftforge.common.crafting.IConditionFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
public class IsConversionEnabled implements IConditionFactory {
|
||||
|
||||
@Override
|
||||
public BooleanSupplier parse(JsonContext context, JsonObject json) {
|
||||
return () -> IWConfig.enableConversion;
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package malte0811.industrialWires.crafting.factories;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import malte0811.industrialWires.crafting.RecipeCoilLength;
|
||||
import malte0811.industrialWires.crafting.RecipeInitPC;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.IRecipeFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
public class WireCoilFactory implements IRecipeFactory {
|
||||
@Override
|
||||
public RecipeCoilLength parse(JsonContext context, JsonObject json) {
|
||||
JsonObject coil = json.getAsJsonObject("coil");
|
||||
JsonObject cable = json.getAsJsonObject("cable");
|
||||
return new RecipeCoilLength(CraftingHelper.getItemStack(coil, context), CraftingHelper.getIngredient(cable, context));
|
||||
}
|
||||
}
|
|
@ -1,232 +0,0 @@
|
|||
/*
|
||||
* 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.items;
|
||||
|
||||
import blusunrize.immersiveengineering.api.Lib;
|
||||
import blusunrize.immersiveengineering.api.TargetingInfo;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IWireCoil;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.common.IESaveData;
|
||||
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemIC2Coil extends Item implements IWireCoil {
|
||||
public final static String[] subNames = {"tin", "copper", "gold", "hv", "glass"};
|
||||
public final static String lengthKey = "wireLength";
|
||||
public final static String NAME = "ic2_wire_coil";
|
||||
|
||||
public ItemIC2Coil() {
|
||||
setUnlocalizedName(IndustrialWires.MODID + "."+NAME);
|
||||
setHasSubtypes(true);
|
||||
this.setCreativeTab(IndustrialWires.creativeTab);
|
||||
setMaxStackSize(64);
|
||||
setRegistryName(new ResourceLocation(IndustrialWires.MODID, NAME));
|
||||
IndustrialWires.items.add(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
|
||||
if (isInCreativeTab(tab)) {
|
||||
for (int i = 0; i < subNames.length; i++) {
|
||||
ItemStack tmp = new ItemStack(this, 1, i);
|
||||
setLength(tmp, getMaxWireLength(tmp));
|
||||
subItems.add(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return this.getUnlocalizedName() + "." + subNames[stack.getMetadata()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public WireType getWireType(ItemStack stack) {
|
||||
return IC2Wiretype.IC2_TYPES[stack.getMetadata()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".desc.wireLength", getLength(stack)));
|
||||
int transferRate = IC2Wiretype.IC2_TYPES[stack.getMetadata()].getTransferRate();
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.transfer_rate", transferRate));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.input_rate", transferRate / 8));
|
||||
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("linkingPos")) {
|
||||
int[] link = stack.getTagCompound().getIntArray("linkingPos");
|
||||
if (link.length > 3) {
|
||||
tooltip.add(I18n.format(Lib.DESC_INFO + "attachedToDim", link[1], link[2], link[3], link[0]));
|
||||
}
|
||||
}
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".desc.recipe"));
|
||||
}
|
||||
|
||||
//mostly copied from IE
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (!world.isRemote && !stack.isEmpty()) {
|
||||
if (stack.getCount() > 1) {
|
||||
player.sendMessage(new TextComponentTranslation(IndustrialWires.MODID + ".chat.stackSize"));
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (tileEntity instanceof IImmersiveConnectable && ((IImmersiveConnectable) tileEntity).canConnect()) {
|
||||
TargetingInfo target = new TargetingInfo(side, hitX, hitY, hitZ);
|
||||
WireType wire = getWireType(stack);
|
||||
BlockPos masterPos = ((IImmersiveConnectable) tileEntity).getConnectionMaster(wire, target);
|
||||
tileEntity = world.getTileEntity(masterPos);
|
||||
if (!(tileEntity instanceof IImmersiveConnectable) || !((IImmersiveConnectable) tileEntity).canConnect()) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
if (!((IImmersiveConnectable) tileEntity).canConnectCable(wire, target)) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "wrongCable"));
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!ItemNBTHelper.hasKey(stack, "linkingPos")) {
|
||||
ItemNBTHelper.setIntArray(stack, "linkingPos", new int[]{world.provider.getDimension(), masterPos.getX(), masterPos.getY(), masterPos.getZ()});
|
||||
target.writeToNBT(stack.getTagCompound());
|
||||
} else {
|
||||
WireType type = getWireType(stack);
|
||||
int[] array = ItemNBTHelper.getIntArray(stack, "linkingPos");
|
||||
BlockPos linkPos = new BlockPos(array[1], array[2], array[3]);
|
||||
TileEntity tileEntityLinkingPos = world.getTileEntity(linkPos);
|
||||
int distanceSq = (int) Math.ceil(linkPos.distanceSq(masterPos));
|
||||
if (array[0] != world.provider.getDimension()) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "wrongDimension"));
|
||||
} else if (linkPos.equals(masterPos)) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "sameConnection"));
|
||||
} else if (distanceSq > (type.getMaxLength() * type.getMaxLength())) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "tooFar"));
|
||||
} else if (!(tileEntityLinkingPos instanceof IImmersiveConnectable) || !((IImmersiveConnectable) tileEntityLinkingPos).canConnectCable(type, TargetingInfo.readFromNBT(stack.getTagCompound()))) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "invalidPoint"));
|
||||
} else {
|
||||
IImmersiveConnectable nodeHere = (IImmersiveConnectable) tileEntity;
|
||||
IImmersiveConnectable nodeLink = (IImmersiveConnectable) tileEntityLinkingPos;
|
||||
boolean connectionExists = false;
|
||||
Set<Connection> outputs = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(nodeHere));
|
||||
if (outputs != null) {
|
||||
for (Connection con : outputs) {
|
||||
if (con.end.equals(Utils.toCC(nodeLink))) {
|
||||
connectionExists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (connectionExists) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "connectionExists"));
|
||||
} else {
|
||||
Vec3d rtOff0 = nodeHere.getRaytraceOffset(nodeLink).addVector(masterPos.getX(), masterPos.getY(), masterPos.getZ());
|
||||
Vec3d rtOff1 = nodeLink.getRaytraceOffset(nodeHere).addVector(linkPos.getX(), linkPos.getY(), linkPos.getZ());
|
||||
Set<BlockPos> ignore = new HashSet<>();
|
||||
ignore.addAll(nodeHere.getIgnored(nodeLink));
|
||||
ignore.addAll(nodeLink.getIgnored(nodeHere));
|
||||
boolean canSee = Utils.rayTraceForFirst(rtOff0, rtOff1, world, ignore) == null;
|
||||
if (canSee) {
|
||||
int lengthOnStack = getLength(stack);
|
||||
int length = (int) Math.sqrt(distanceSq);
|
||||
if (length <= lengthOnStack) {
|
||||
TargetingInfo targetLink = TargetingInfo.readFromNBT(stack.getTagCompound());
|
||||
ImmersiveNetHandler.INSTANCE.addConnection(world, Utils.toCC(nodeHere), Utils.toCC(nodeLink), length, type);
|
||||
|
||||
nodeHere.connectCable(type, target, nodeLink);
|
||||
nodeLink.connectCable(type, targetLink, nodeHere);
|
||||
IESaveData.setDirty(world.provider.getDimension());
|
||||
Utils.unlockIEAdvancement(player, "main/connect_wire");
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (length < lengthOnStack) {
|
||||
setLength(stack, lengthOnStack - length);
|
||||
} else {
|
||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
((TileEntity) nodeHere).markDirty();
|
||||
world.addBlockEvent(masterPos, ((TileEntity) nodeHere).getBlockType(), -1, 0);
|
||||
IBlockState state = world.getBlockState(masterPos);
|
||||
world.notifyBlockUpdate(masterPos, state, state, 3);
|
||||
((TileEntity) nodeLink).markDirty();
|
||||
world.addBlockEvent(linkPos, ((TileEntity) nodeLink).getBlockType(), -1, 0);
|
||||
state = world.getBlockState(linkPos);
|
||||
world.notifyBlockUpdate(linkPos, state, state, 3);
|
||||
} else {
|
||||
player.sendMessage(new TextComponentTranslation(IndustrialWires.MODID + ".chat.tooLong"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "cantSee"));
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemNBTHelper.remove(stack, "linkingPos");
|
||||
ItemNBTHelper.remove(stack, "side");
|
||||
ItemNBTHelper.remove(stack, "hitX");
|
||||
ItemNBTHelper.remove(stack, "hitY");
|
||||
ItemNBTHelper.remove(stack, "hitZ");
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
public static void setLength(ItemStack i, int blocks) {
|
||||
i.setTagInfo(lengthKey, new NBTTagInt(blocks));
|
||||
}
|
||||
|
||||
public static int getLength(ItemStack i) {
|
||||
if (i.getTagCompound() == null) {
|
||||
setLength(i, 4);
|
||||
}
|
||||
return i.getTagCompound().getInteger(lengthKey);
|
||||
}
|
||||
|
||||
public static int getMaxWireLength(ItemStack i) {
|
||||
return IWConfig.maxLengthOnCoil[i.getItemDamage()];
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
* 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.util;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class DualEnergyStorage {
|
||||
private double storedEU;
|
||||
private double maxEU;
|
||||
private double maxOutEU;
|
||||
private double maxInEU;
|
||||
|
||||
public DualEnergyStorage(double maxEU, double maxInEU, double maxOutEU) {
|
||||
this(0, maxEU, maxInEU, maxOutEU);
|
||||
}
|
||||
|
||||
public DualEnergyStorage(double storedEU, double maxEU, double maxInEU, double maxOutEU) {
|
||||
this.maxEU = maxEU;
|
||||
this.maxInEU = maxInEU;
|
||||
this.maxOutEU = maxOutEU;
|
||||
this.storedEU = storedEU;
|
||||
}
|
||||
|
||||
public DualEnergyStorage(double maxEU, double maxIoEU) {
|
||||
this(maxEU, maxIoEU, maxIoEU);
|
||||
}
|
||||
|
||||
public DualEnergyStorage(double maxEU) {
|
||||
this(maxEU, maxEU, maxEU);
|
||||
}
|
||||
|
||||
public DualEnergyStorage(int maxIF, int maxInIF, int maxOutIF) {
|
||||
this(ConversionUtil.euPerIfIdeal() * maxIF, ConversionUtil.euPerIfIdeal() * maxInIF, ConversionUtil.euPerIfIdeal() * maxOutIF);
|
||||
}
|
||||
|
||||
public DualEnergyStorage(int maxIF, int maxIoIF) {
|
||||
this(maxIF, maxIoIF, maxIoIF);
|
||||
}
|
||||
|
||||
public DualEnergyStorage(int maxIF) {
|
||||
this(maxIF, maxIF, maxIF);
|
||||
}
|
||||
|
||||
public double extractEU(double extractMax, boolean doExtract) {
|
||||
double extr = Math.min(storedEU, extractMax);
|
||||
if (doExtract) {
|
||||
storedEU -= extr;
|
||||
}
|
||||
return extr;
|
||||
}
|
||||
|
||||
public void extractEURaw(double extract) {
|
||||
storedEU -= extract;
|
||||
}
|
||||
|
||||
public double extractIF(int extractMax, boolean doExtract) {
|
||||
double eu = extractMax * ConversionUtil.euPerIfIdeal();
|
||||
return ConversionUtil.ifPerEuIdeal() * extractEU(eu, doExtract);
|
||||
}
|
||||
|
||||
public double insertEU(double insertMax, boolean doInsert) {
|
||||
return insertEU(insertMax, maxInEU, doInsert);
|
||||
}
|
||||
public double insertEU(double insertMax, double leftover, boolean doInsert) {
|
||||
double ins = Math.min(Math.min(insertMax, maxEU - storedEU), leftover);
|
||||
if (doInsert) {
|
||||
storedEU += ins;
|
||||
}
|
||||
return ins;
|
||||
}
|
||||
|
||||
public double insertIF(int insertMax, boolean doInsert) {
|
||||
return insertIF(insertMax, ConversionUtil.ifPerEuIdeal()*maxInEU, doInsert);
|
||||
}
|
||||
public double insertIF(int insertMax, double leftover, boolean doInsert) {
|
||||
double eu = insertMax * ConversionUtil.euPerIfIdeal();
|
||||
double euMax = leftover* ConversionUtil.euPerIfIdeal();
|
||||
return ConversionUtil.ifPerEuIdeal() * insertEU(eu, euMax, doInsert);
|
||||
}
|
||||
|
||||
public double getEnergyStoredEU() {
|
||||
return storedEU;
|
||||
}
|
||||
|
||||
public double getMaxStoredEU() {
|
||||
return maxEU;
|
||||
}
|
||||
|
||||
public double getEnergyStoredIF() {
|
||||
return storedEU * ConversionUtil.ifPerEuIdeal();
|
||||
}
|
||||
|
||||
public double getMaxStoredIF() {
|
||||
return maxEU * ConversionUtil.ifPerEuIdeal();
|
||||
}
|
||||
|
||||
public double getEURequested() {
|
||||
return Math.min(maxInEU, maxEU - storedEU);
|
||||
}
|
||||
|
||||
public void writeToNbt(NBTTagCompound nbtOuter, String key) {
|
||||
NBTTagCompound nbt = key == null ? nbtOuter : new NBTTagCompound();
|
||||
nbt.setDouble("stored", storedEU);
|
||||
nbt.setDouble("maxStored", maxEU);
|
||||
nbt.setDouble("maxIn", maxInEU);
|
||||
nbt.setDouble("maxOut", maxOutEU);
|
||||
if (key != null) {
|
||||
nbtOuter.setTag(key, nbt);
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
storedEU = nbt.getDouble("stored");
|
||||
}
|
||||
|
||||
public double getMaxInputIF() {
|
||||
return maxInEU*ConversionUtil.ifPerEuIdeal();
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* 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.wires;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class IC2Wiretype extends WireType {
|
||||
final int type;
|
||||
final int[] ic2Rates = {32 * 8, 128 * 8, 512 * 8, 2048 * 8, 8192 * 8};
|
||||
final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9, 0xf1f1f1};
|
||||
final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv", "ic2Glass"};
|
||||
final double[] lossPerBlock = {.2, .2, .4, .8, .025};
|
||||
final double[] ic2RenderDiameter = {.03125, .03125, .046875, .0625, .75 * .03125};
|
||||
public static final IC2Wiretype[] IC2_TYPES = {new IC2Wiretype(0), new IC2Wiretype(1), new IC2Wiretype(2), new IC2Wiretype(3), new IC2Wiretype(4)};
|
||||
|
||||
public IC2Wiretype(int ordinal) {
|
||||
super();
|
||||
this.type = ordinal;
|
||||
}
|
||||
|
||||
/**
|
||||
* In this case, this does not return the loss RATIO but the loss PER BLOCK
|
||||
*/
|
||||
@Override
|
||||
public double getLossRatio() {
|
||||
return lossPerBlock[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransferRate() {
|
||||
return ic2Rates[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour(Connection connection) {
|
||||
return ic2Colors[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSlack() {
|
||||
return type == 2 ? 1.03 : 1.005;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getIcon(Connection connection) {
|
||||
return iconDefaultWire;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLength() {
|
||||
return IWConfig.maxLengthPerConn[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWireCoil(ImmersiveNetHandler.Connection con) {
|
||||
ItemStack ret = getWireCoil();
|
||||
ItemIC2Coil.setLength(ret, con.length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWireCoil() {
|
||||
return new ItemStack(IndustrialWires.coil, 1, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueName() {
|
||||
return ic2Names[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRenderDiameter() {
|
||||
return ic2RenderDiameter[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnergyWire() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,41 +1,41 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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;
|
||||
package malte0811.industrialwires;
|
||||
|
||||
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 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 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 net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
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 TileEntityRSPanelConn) {
|
||||
return new ContainerRSPanelConn((TileEntityRSPanelConn) te);
|
||||
if (te instanceof TileEntityRSPanel) {
|
||||
return new ContainerRSPanelConn((TileEntityRSPanel) te);
|
||||
}
|
||||
} else if (ID == 1) {//ITEM GUI
|
||||
EnumHand h = z == 1 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
|
||||
|
@ -83,4 +83,16 @@ 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;
|
||||
}
|
||||
}
|
68
src/main/java/malte0811/industrialwires/EventHandler.java
Normal file
68
src/main/java/malte0811/industrialwires/EventHandler.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import malte0811.industrialwires.items.ItemIC2Coil;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class EventHandler {
|
||||
@SubscribeEvent
|
||||
public static void onItemPickup(EntityItemPickupEvent ev) {
|
||||
if (ev.getItem().getItem().getItem()==IndustrialWires.coil) {
|
||||
ItemStack stack = ev.getItem().getItem();
|
||||
InventoryPlayer playerInv = ev.getEntityPlayer().inventory;
|
||||
boolean changed = false;
|
||||
int lengthOnEntity = ItemIC2Coil.getLength(stack);
|
||||
final int lengthPerCoilOrig = lengthOnEntity/stack.getCount();
|
||||
for (int i = 0;i<playerInv.getSizeInventory();i++) {
|
||||
ItemStack inInv = playerInv.getStackInSlot(i);
|
||||
if (ItemStack.areItemsEqual(stack, inInv)) {
|
||||
int oldLength = ItemIC2Coil.getLength(inInv);
|
||||
int newLength = Math.min(oldLength+lengthOnEntity, ItemIC2Coil.getMaxWireLength(inInv));
|
||||
ItemIC2Coil.setLength(inInv, newLength);
|
||||
lengthOnEntity -= newLength-oldLength;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
ev.getEntityPlayer().onItemPickup(ev.getItem(), 1);
|
||||
}
|
||||
if (lengthOnEntity==0) {
|
||||
ev.getItem().setDead();
|
||||
ev.setCanceled(true);
|
||||
} else if (stack.getCount()>1) {
|
||||
int coilsRemaining = lengthOnEntity/lengthPerCoilOrig;
|
||||
stack.setCount(coilsRemaining);
|
||||
int leftover = lengthOnEntity-lengthPerCoilOrig*coilsRemaining;
|
||||
if (leftover>0) {
|
||||
EntityItem old = ev.getItem();
|
||||
ItemStack leftoverItem = new ItemStack(stack.getItem(), 1, stack.getMetadata());
|
||||
ItemIC2Coil.setLength(leftoverItem, leftover);
|
||||
EntityItem newCoil = new EntityItem(old.world, old.posX, old.posY, old.posZ, leftoverItem);
|
||||
old.world.spawnEntity(newCoil);
|
||||
}
|
||||
} else if (stack.getCount()==1) {
|
||||
ItemIC2Coil.setLength(stack, lengthOnEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
55
src/main/java/malte0811/industrialwires/IEObjects.java
Normal file
55
src/main/java/malte0811/industrialwires/IEObjects.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import blusunrize.immersiveengineering.ImmersiveEngineering;
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockIEBase;
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
public class IEObjects {
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":metal_decoration0")
|
||||
public static BlockIEBase<BlockTypes_MetalDecoration0> blockMetalDecoration0 = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":metal_decoration1")
|
||||
public static BlockIEBase<BlockTypes_MetalDecoration1> blockMetalDecoration1 = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":metal_decoration2")
|
||||
public static BlockIEBase<BlockTypes_MetalDecoration2> blockMetalDecoration2 = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":metal_device0")
|
||||
public static BlockIEBase<BlockTypes_MetalDevice0> blockMetalDevice0 = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":connector")
|
||||
public static BlockIEBase<BlockTypes_Connector> blockConnectors = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":storage")
|
||||
public static BlockIEBase<BlockTypes_MetalsIE> blockStorage = nullNotNull();
|
||||
|
||||
//ITEMS
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":earmuffs")
|
||||
public static Item itemEarmuffs = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":material")
|
||||
public static Item itemMaterial = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":wirecoil")
|
||||
public static Item itemWireCoil = nullNotNull();
|
||||
@GameRegistry.ObjectHolder(ImmersiveEngineering.MODID+":tool")
|
||||
public static Item itemTool = nullNotNull();
|
||||
|
||||
|
||||
// Ugly hack to prevent null warnings
|
||||
private static <T> T nullNotNull() {
|
||||
//noinspection ConstantConditions
|
||||
return null;
|
||||
}
|
||||
}
|
33
src/main/java/malte0811/industrialwires/IMixedConnector.java
Normal file
33
src/main/java/malte0811/industrialwires/IMixedConnector.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import malte0811.industrialwires.util.ConversionUtil;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface IMixedConnector extends IImmersiveConnectable {
|
||||
/**
|
||||
* @return leftover energy.
|
||||
*/
|
||||
double insertEnergy(double joules, boolean simulate);
|
||||
|
||||
@Override
|
||||
default float getDamageAmount(Entity e, ImmersiveNetHandler.Connection c)
|
||||
{
|
||||
return (float) Math.ceil(IImmersiveConnectable.super.getDamageAmount(e, c) * ConversionUtil.euPerJoule());//Same as IC2 uses
|
||||
}
|
||||
}
|
|
@ -1,33 +1,45 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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;
|
||||
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;
|
||||
|
@ -41,26 +53,44 @@ 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"})
|
||||
public static double maxRotToKin = 50;
|
||||
@Config.RequiresWorldRestart
|
||||
public static double maxRotToKin = 200;
|
||||
@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"})
|
||||
public static int maxKinToRot = 2400;
|
||||
@Config.RequiresWorldRestart
|
||||
public static int maxKinToRot = 600;
|
||||
@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[] jacobsUsageEU = {20, 50, 100};
|
||||
public static double[] jacobsUsageWatt = {40, 300, 2000};
|
||||
@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.",
|
||||
|
@ -69,4 +99,11 @@ 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,22 +1,19 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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;
|
||||
package malte0811.industrialwires;
|
||||
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
|
@ -1,22 +1,19 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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;
|
||||
package malte0811.industrialwires;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -40,7 +37,7 @@ public class IWPotions {
|
|||
setIconIndex(0, 0);
|
||||
this.setRegistryName(new ResourceLocation(IndustrialWires.MODID, "tinnitus"));
|
||||
ForgeRegistries.POTIONS.register(this);
|
||||
this.setPotionName("potion."+ IndustrialWires.MODID+"." + getRegistryName().getResourcePath());
|
||||
this.setPotionName("potion." + IndustrialWires.MODID + "." + getRegistryName().getPath());
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,24 +1,21 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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;
|
||||
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;
|
322
src/main/java/malte0811/industrialwires/IndustrialWires.java
Normal file
322
src/main/java/malte0811/industrialwires/IndustrialWires.java
Normal file
|
@ -0,0 +1,322 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import blusunrize.immersiveengineering.ImmersiveEngineering;
|
||||
import blusunrize.immersiveengineering.api.MultiblockHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireApi;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import malte0811.industrialwires.blocks.BlockIWBase;
|
||||
import malte0811.industrialwires.blocks.TEDataFixer;
|
||||
import malte0811.industrialwires.blocks.controlpanel.*;
|
||||
import malte0811.industrialwires.blocks.converter.*;
|
||||
import malte0811.industrialwires.blocks.hv.*;
|
||||
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.entities.EntityBrokenPart;
|
||||
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.mech_mb.EUCapability;
|
||||
import malte0811.industrialwires.mech_mb.MechMBPart;
|
||||
import malte0811.industrialwires.mech_mb.MultiblockMechMB;
|
||||
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 malte0811.industrialwires.util.MultiblockTemplateManual;
|
||||
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.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.datafix.FixTypes;
|
||||
import net.minecraftforge.common.util.ModFixs;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
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.EntityRegistry;
|
||||
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;
|
||||
|
||||
import static malte0811.industrialwires.blocks.wire.BlockTypes_IC2_Connector.*;
|
||||
import static malte0811.industrialwires.entities.EntityBrokenPart.MARKER_TEXTURE;
|
||||
import static malte0811.industrialwires.entities.EntityBrokenPart.RES_LOC_SERIALIZER;
|
||||
import static malte0811.industrialwires.mech_mb.MechMBPart.EXAMPLE_MECHMB_LOC;
|
||||
import static malte0811.industrialwires.wires.MixedWireType.*;
|
||||
|
||||
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.12-86,);after:ic2;required-after:forge@[14.23.3.2694,)",
|
||||
certificateFingerprint = "7e11c175d1e24007afec7498a1616bef0000027d",
|
||||
updateJSON = "https://raw.githubusercontent.com/malte0811/IndustrialWires/MC1.12/changelog.json")
|
||||
@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 int DATAFIXER_VER = 1;
|
||||
public static final SoundEvent TINNITUS = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "tinnitus"));
|
||||
public static final SoundEvent LADDER_START = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_start"));//~470 ms ~=9 ticks
|
||||
public static final SoundEvent LADDER_MIDDLE = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_middle"));
|
||||
public static final SoundEvent LADDER_END = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_end"));//~210 ms ~= 4 ticks
|
||||
public static final SoundEvent MARX_BANG = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "marx_bang"));
|
||||
public static final SoundEvent MARX_POP = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "marx_pop"));
|
||||
public static final SoundEvent TURN_FAST = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "mech_mb_fast"));
|
||||
public static final SoundEvent TURN_SLOW = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "mech_mb_slow"));
|
||||
public static final SoundEvent MMB_BREAKING = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "mech_mb_breaking"));
|
||||
|
||||
private static final SoundEvent createSoundEvent(ResourceLocation loc) {
|
||||
return new SoundEvent(loc).setRegistryName(loc);
|
||||
}
|
||||
|
||||
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+":"+BlockMechanicalMB.NAME)
|
||||
public static BlockMechanicalMB mechanicalMB = null;
|
||||
@GameRegistry.ObjectHolder(MODID+":"+ BlockGeneralHV.NAME)
|
||||
public static BlockGeneralHV generalHV = 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;
|
||||
|
||||
|
||||
@GameRegistry.ObjectHolder("ic2:te")
|
||||
public static Block ic2TeBlock = 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 createIcon() {
|
||||
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();
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorTin.class, new ResourceLocation(MODID, "ic2ConnectorTin"));
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorCopper.class, new ResourceLocation(MODID, "ic2ConnectorCopper"));
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, new ResourceLocation(MODID, "ic2ConnectorGold"));
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorHV.class, new ResourceLocation(MODID, "ic2ConnectorHV"));
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGlass.class, new ResourceLocation(MODID, "ic2ConnectorGlass"));
|
||||
|
||||
if (hasIC2 && IWConfig.enableConversion) {
|
||||
GameRegistry.registerTileEntity(TileEntityIEMotor.class, new ResourceLocation(MODID, "ieMotor"));
|
||||
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, new ResourceLocation(MODID, "mechIcToIe"));
|
||||
GameRegistry.registerTileEntity(TileEntityMechIEtoIC.class, new ResourceLocation(MODID, "mechIeToIc"));
|
||||
}
|
||||
GameRegistry.registerTileEntity(TileEntityMechMB.class, new ResourceLocation(MODID, "mechMB"));
|
||||
GameRegistry.registerTileEntity(TileEntityJacobsLadder.class, new ResourceLocation(MODID, "jacobsLadder"));
|
||||
GameRegistry.registerTileEntity(TileEntityMarx.class, new ResourceLocation(MODID, "marx_generator"));
|
||||
GameRegistry.registerTileEntity(TileEntityPanel.class, new ResourceLocation(MODID, "control_panel"));
|
||||
GameRegistry.registerTileEntity(TileEntityGeneralCP.class, new ResourceLocation(MODID, "gcp"));
|
||||
GameRegistry.registerTileEntity(TileEntityRSPanelIE.class, new ResourceLocation(MODID, "control_panel_rs"));
|
||||
GameRegistry.registerTileEntity(TileEntityRSPanelOthers.class, new ResourceLocation(MODID, "control_panel_rs_compat"));
|
||||
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, new ResourceLocation(MODID, "panel_creator"));
|
||||
GameRegistry.registerTileEntity(TileEntityUnfinishedPanel.class, new ResourceLocation(MODID, "unfinished_panel"));
|
||||
GameRegistry.registerTileEntity(TileEntityComponentPanel.class, new ResourceLocation(MODID, "single_component_panel"));
|
||||
GameRegistry.registerTileEntity(TileEntityDischargeMeter.class, new ResourceLocation(MODID, "discharge_meter"));
|
||||
|
||||
DataSerializers.registerSerializer(RES_LOC_SERIALIZER);
|
||||
MARKER_TEXTURE = EntityDataManager.createKey(EntityBrokenPart.class, RES_LOC_SERIALIZER);
|
||||
EntityRegistry.registerModEntity(new ResourceLocation(MODID, "broken_part"), EntityBrokenPart.class,
|
||||
"broken_part", 0, this, 64, 5, true);
|
||||
|
||||
proxy.preInit();
|
||||
Compat.preInit();
|
||||
MarxOreHandler.preInit();
|
||||
// This has to run before textures are stitched, i.e. in preInit
|
||||
MechMBPart.preInit();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event) {
|
||||
|
||||
if (IWConfig.enableConversion&&hasIC2) {
|
||||
event.getRegistry().register(new BlockMechanicalConverter());
|
||||
}
|
||||
event.getRegistry().register(new BlockIC2Connector());
|
||||
event.getRegistry().register(new BlockJacobsLadder());
|
||||
event.getRegistry().register(new BlockPanel());
|
||||
event.getRegistry().register(new BlockHVMultiblocks());
|
||||
event.getRegistry().register(new BlockMechanicalMB());
|
||||
event.getRegistry().register(new BlockGeneralHV());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||
for (BlockIWBase b:blocks) {
|
||||
event.getRegistry().register(b.createItemBlock());
|
||||
}
|
||||
|
||||
event.getRegistry().register(new ItemIC2Coil());
|
||||
event.getRegistry().register(new ItemPanelComponent());
|
||||
event.getRegistry().register(new ItemKey());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerSounds(RegistryEvent.Register<SoundEvent> event) {
|
||||
event.getRegistry().register(TINNITUS);
|
||||
event.getRegistry().register(LADDER_START);
|
||||
event.getRegistry().register(LADDER_MIDDLE);
|
||||
event.getRegistry().register(LADDER_END);
|
||||
event.getRegistry().register(MARX_BANG);
|
||||
event.getRegistry().register(MARX_POP);
|
||||
event.getRegistry().register(TURN_FAST);
|
||||
event.getRegistry().register(TURN_SLOW);
|
||||
event.getRegistry().register(MMB_BREAKING);
|
||||
}
|
||||
|
||||
@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);
|
||||
MultiblockMechMB.INSTANCE = new MultiblockMechMB();
|
||||
MultiblockHandler.registerMultiblock(MultiblockMechMB.INSTANCE);
|
||||
MultiblockHandler.registerMultiblock(new MultiblockTemplateManual(EXAMPLE_MECHMB_LOC));
|
||||
|
||||
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);
|
||||
|
||||
if (hasIC2) {
|
||||
ResourceLocation tex = new ResourceLocation(MODID, "blocks/ic2_conn_tin");
|
||||
float[] uvs = {3, 4, 11, 12};
|
||||
WireApi.registerFeedthroughForWiretype(TIN, new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_tin"), tex, uvs, .5, .5,
|
||||
ic2conn.getDefaultState().withProperty(BlockIC2Connector.TYPE, TIN_CONN),
|
||||
1/64F, TIN.getTransferRate(), f->(float)Math.ceil(f));
|
||||
|
||||
WireApi.registerFeedthroughForWiretype(COPPER_IC2, new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_copper"), tex, uvs, .5, .5,
|
||||
ic2conn.getDefaultState().withProperty(BlockIC2Connector.TYPE, COPPER_CONN),
|
||||
1/64F, COPPER_IC2.getTransferRate(), f->(float)Math.ceil(f));
|
||||
|
||||
WireApi.registerFeedthroughForWiretype(GOLD, new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_gold"), tex, uvs, .5625, .5625,
|
||||
ic2conn.getDefaultState().withProperty(BlockIC2Connector.TYPE, GOLD_CONN),
|
||||
1/64F, GOLD.getTransferRate(), f->(float)Math.ceil(f));
|
||||
|
||||
WireApi.registerFeedthroughForWiretype(HV, new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_hv"), tex, uvs, .75, .75,
|
||||
ic2conn.getDefaultState().withProperty(BlockIC2Connector.TYPE, HV_CONN),
|
||||
1/64F, HV.getTransferRate(), f->(float)Math.ceil(f));
|
||||
|
||||
WireApi.registerFeedthroughForWiretype(GLASS, new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_glass"), tex, uvs, .75, .75,
|
||||
ic2conn.getDefaultState().withProperty(BlockIC2Connector.TYPE, GLASS_CONN),
|
||||
1/64F, GLASS.getTransferRate(), f->(float)Math.ceil(f));
|
||||
}
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
||||
IWPotions.init();
|
||||
Compat.init();
|
||||
MarxOreHandler.init();
|
||||
PanelComponent.init();
|
||||
MechMBPart.init();
|
||||
if (hasIC2) {
|
||||
EUCapability.register();
|
||||
}
|
||||
ModFixs fixer = FMLCommonHandler.instance().getDataFixer().init(MODID, DATAFIXER_VER);
|
||||
fixer.registerFix(FixTypes.BLOCK_ENTITY, new TEDataFixer());
|
||||
}
|
||||
|
||||
@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,30 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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;
|
||||
|
@ -57,7 +55,7 @@ public abstract class BlockIWBase extends Block {
|
|||
super(mat);
|
||||
setHardness(3.0F);
|
||||
setResistance(15.0F);
|
||||
setUnlocalizedName(IndustrialWires.MODID + "." + name);
|
||||
setTranslationKey(IndustrialWires.MODID + "." + name);
|
||||
setRegistryName(IndustrialWires.MODID, name);
|
||||
setCreativeTab(IndustrialWires.creativeTab);
|
||||
IndustrialWires.blocks.add(this);
|
||||
|
@ -181,8 +179,9 @@ public abstract class BlockIWBase extends Block {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
} else if (te instanceof IEBlockInterfaces.IPlayerInteraction) {
|
||||
if (((IEBlockInterfaces.IPlayerInteraction) te).interact(side, player, hand, heldItem, hitX, hitY, hitZ)) {
|
||||
}
|
||||
if (te instanceof IPlayerInteraction) {
|
||||
if (((IPlayerInteraction) te).interact(side, player, hand, heldItem, hitX, hitY, hitZ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -222,5 +221,34 @@ 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,27 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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;
|
||||
|
@ -76,7 +71,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 MiscUtils.getItemStack(((TileEntityIWMultiblock) te).getOriginalBlock(), world, pos);
|
||||
return ((TileEntityIWMultiblock) te).getOriginalItem();
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
|
@ -1,21 +1,18 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks;
|
||||
package malte0811.industrialwires.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxConnection;
|
||||
import blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxProvider;
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.util.MiscUtils;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
public interface IBlockBoundsIW {
|
||||
AxisAlignedBB getBoundingBox();
|
||||
|
||||
interface IBlockBoundsDirectional extends IBlockBoundsIW, IEBlockInterfaces.IDirectionalTile {
|
||||
|
||||
@Override
|
||||
default AxisAlignedBB getBoundingBox() {
|
||||
EnumFacing dir = getFacing();
|
||||
Matrix4 mat = new Matrix4();
|
||||
mat.translate(.5, 0, .5);
|
||||
mat.rotate((-dir.getHorizontalAngle()+180)*Math.PI/180, 0, 1, 0);
|
||||
mat.translate(-.5, 0, -.5);
|
||||
return MiscUtils.apply(mat, getBoundingBoxNoRot());
|
||||
}
|
||||
|
||||
AxisAlignedBB getBoundingBoxNoRot();
|
||||
}
|
||||
}
|
|
@ -1,24 +1,20 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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,21 +1,18 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks;
|
||||
package malte0811.industrialwires.blocks;
|
||||
|
||||
public interface IMetaEnum {
|
||||
Object[] getValues();
|
|
@ -1,22 +1,19 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks;
|
||||
package malte0811.industrialwires.blocks;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
|
@ -1,22 +1,19 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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-2017 malte0811
|
||||
*
|
||||
* 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.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);
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.blocks;
|
||||
|
||||
import malte0811.industrialwires.util.MBSideConfig;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
public final class IWProperties {
|
||||
private IWProperties() {}
|
||||
public static final PropertyEnum<MarxType> MARX_TYPE = PropertyEnum.create("marx_type", MarxType.class);
|
||||
public static final IUnlistedProperty<MBSideConfig> MB_SIDES = new MBSideConfigProperty();
|
||||
public enum MarxType implements IStringSerializable {
|
||||
NO_MODEL,
|
||||
BOTTOM,
|
||||
STAGE,
|
||||
TOP,
|
||||
CONNECTOR;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static class MBSideConfigProperty implements IUnlistedProperty<MBSideConfig> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "mb_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(MBSideConfig value) {
|
||||
return value!=null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<MBSideConfig> getType() {
|
||||
return MBSideConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString(MBSideConfig value) {
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +1,21 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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;
|
||||
|
@ -48,12 +45,12 @@ public class ItemBlockIW extends ItemBlock {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
public String getTranslationKey(ItemStack stack) {
|
||||
int meta = stack.getMetadata();
|
||||
if (values != null) {
|
||||
return block.getUnlocalizedName() + "." + values[meta].toString().toLowerCase();
|
||||
return block.getTranslationKey() + "." + values[meta].toString().toLowerCase();
|
||||
} else {
|
||||
return block.getUnlocalizedName();
|
||||
return block.getTranslationKey();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.blocks;
|
||||
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TEDataFixer implements IFixableData {
|
||||
private static final String PREFIX = "minecraft:"+IndustrialWires.MODID;
|
||||
private static final int PREFIX_LEN = PREFIX.length();
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound fixTagCompound(@Nonnull NBTTagCompound compound) {
|
||||
String id = compound.getString("id");
|
||||
if (id.startsWith(PREFIX)) {
|
||||
compound.setString("id", IndustrialWires.MODID+":"+id.substring(PREFIX_LEN));
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixVersion() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,33 +1,32 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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
|
||||
|
@ -57,11 +56,36 @@ 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,27 +1,25 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks;
|
||||
package malte0811.industrialwires.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
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;
|
||||
|
@ -35,14 +33,15 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements IGeneralMultiblock {
|
||||
public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements IGeneralMultiblock,
|
||||
IDirectionalTile {
|
||||
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, 0, 0);
|
||||
public Vec3i offset = new Vec3i(0, 1, 0);
|
||||
public boolean formed;
|
||||
public boolean mirrored;
|
||||
public long onlyLocalDissassembly;
|
||||
|
@ -50,6 +49,10 @@ 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());
|
||||
}
|
||||
|
@ -75,6 +78,7 @@ 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();
|
||||
|
@ -94,7 +98,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 = MiscUtils.getItemStack(part.getOriginalBlock(), world, pos);
|
||||
ItemStack drop = getOriginalItem();
|
||||
world.spawnEntity(new EntityItem(world, pos.getX()+.5,pos.getY()+.5,pos.getZ()+.5, drop));
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +123,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.getHorizontal(in.getInteger(FACING));
|
||||
facing = EnumFacing.byHorizontalIndex(in.getInteger(FACING));
|
||||
}
|
||||
|
||||
public Vec3i getSize() {
|
||||
|
@ -137,4 +141,36 @@ 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,30 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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.PanelUtils;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
@ -50,7 +47,6 @@ 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);
|
||||
|
@ -85,13 +81,17 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
case TOP:
|
||||
return new TileEntityPanel();
|
||||
case RS_WIRE:
|
||||
return new TileEntityRSPanelConn();
|
||||
return new TileEntityRSPanelIE();
|
||||
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 TileEntityRSPanelConn) {
|
||||
} else if (te instanceof TileEntityRSPanelIE) {
|
||||
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 TileEntityRSPanelConn) {
|
||||
if (te instanceof TileEntityRSPanel) {
|
||||
if (!world.isRemote) {
|
||||
player.openGui(IndustrialWires.instance, 0, te.getWorld(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
}
|
||||
|
@ -226,48 +226,7 @@ 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((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();
|
||||
pc.dropItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,8 +254,8 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
|
||||
@Override
|
||||
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
||||
public int getWeakPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
if (state.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
||||
TileEntity te = blockAccess.getTileEntity(pos);
|
||||
if (te instanceof TileEntityComponentPanel) {
|
||||
return ((TileEntityComponentPanel)te).getRSOutput();
|
||||
|
@ -304,4 +263,17 @@ 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,23 +1,21 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks.controlpanel;
|
||||
package malte0811.industrialwires.blocks.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.compat.Compat;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
@ -28,18 +26,18 @@ public enum BlockTypes_Panel implements IStringSerializable {
|
|||
DUMMY,
|
||||
CREATOR,
|
||||
UNFINISHED,
|
||||
SINGLE_COMP;
|
||||
SINGLE_COMP,
|
||||
OTHER_RS_WIRES;
|
||||
|
||||
@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,34 +1,32 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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-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.blocks.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork;
|
||||
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 static malte0811.industrialwires.util.MiscUtils.apply;
|
||||
|
||||
public class TileEntityComponentPanel extends TileEntityPanel {
|
||||
private byte rsOut = 0;
|
||||
public TileEntityComponentPanel() {
|
||||
components = new PropertyComponents.AABBPanelProperties();
|
||||
panelNetwork = new SingleCompNetwork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
if (!world.isRemote) {
|
||||
updateRSInput();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRSInput() {
|
||||
int value = world.getRedstonePowerFromNeighbors(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);
|
||||
}
|
||||
}
|
||||
((SingleCompNetwork)panelNetwork).setGlobalInput((byte) value);
|
||||
}
|
||||
|
||||
public void markBlockForUpdate(BlockPos pos)
|
||||
{
|
||||
if (world!=null) {
|
||||
IBlockState state = world.getBlockState(getBlockPos());
|
||||
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;
|
||||
}
|
||||
|
||||
public int getRSOutput() {
|
||||
return rsOut;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getTileDrop(EntityPlayer player, @Nonnull IBlockState state) {
|
||||
if (components.size()<1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ItemPanelComponent.stackFromComponent(components.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canJoinNetwork() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setComponent(PanelComponent comp) {
|
||||
components.clear();
|
||||
components.add(comp);
|
||||
comp.setPanel(this);
|
||||
comp.setNetwork(panelNetwork);
|
||||
}
|
||||
|
||||
private class SingleCompNetwork extends ControlPanelNetwork {
|
||||
@Override
|
||||
public void setOutputs(IOwner owner, RSChannelState... out) {
|
||||
super.setOutputs(owner, out);
|
||||
byte oldOut = rsOut;
|
||||
rsOut = 0;
|
||||
for (OutputValue s:activeOutputs.values()) {
|
||||
rsOut = (byte) Math.max(rsOut, s.getTargetState().getStrength());
|
||||
}
|
||||
if (oldOut!=rsOut) {
|
||||
markBlockForUpdate(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void setGlobalInput(byte value) {
|
||||
for (RSChannel channel: listeners.keySet()) {
|
||||
RSChannelState state = new RSChannelState(channel, value);
|
||||
for (ChangeListener l:listeners.get(channel)) {
|
||||
l.onChange(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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.blocks.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.IOwner;
|
||||
import malte0811.industrialwires.util.MiscUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileEntityGeneralCP extends TileEntityIWBase implements IOwner {
|
||||
@Nonnull
|
||||
protected ControlPanelNetwork panelNetwork = new ControlPanelNetwork();
|
||||
|
||||
public void setNetworkAndInit(ControlPanelNetwork newNet) {
|
||||
panelNetwork = newNet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
if (!world.isRemote) {
|
||||
boolean isFinalNet = false;
|
||||
if (canJoinNetwork()) {
|
||||
for (EnumFacing side : EnumFacing.VALUES) {
|
||||
BlockPos posSide = pos.offset(side);
|
||||
TileEntityGeneralCP neighbour = MiscUtils.getLoadedTE(world, posSide, TileEntityGeneralCP.class);
|
||||
if (neighbour != null && neighbour.canJoinNetwork()) {
|
||||
if (!isFinalNet) {
|
||||
panelNetwork = neighbour.panelNetwork;
|
||||
panelNetwork.addMember(this);
|
||||
isFinalNet = true;
|
||||
} else {
|
||||
neighbour.panelNetwork.replaceWith(panelNetwork, world);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isFinalNet) {
|
||||
panelNetwork.addMember(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
panelNetwork.removeMember(pos, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
panelNetwork.removeMember(pos, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getBlockPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public boolean canJoinNetwork() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,32 +1,29 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialWires.controlpanel.*;
|
||||
import malte0811.industrialWires.network.MessagePanelInteract;
|
||||
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 net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -34,7 +31,6 @@ 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;
|
||||
|
@ -42,22 +38,18 @@ 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 TileEntityIWBase implements IDirectionalTile, IBlockBoundsIW, IPlayerInteraction, ITickable, IEBlockInterfaces.ITileDrop {
|
||||
public class TileEntityPanel extends TileEntityGeneralCP 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 = {
|
||||
|
@ -65,9 +57,10 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
4673362, 10329495, 1481884, 8991416, 3949738, 8606770, 6192150
|
||||
};
|
||||
for (int i = 2; i < 14; i++) {
|
||||
int color = colors[i];
|
||||
IndicatorLight ind = new IndicatorLight(0, (byte) (i - 2), color);
|
||||
LightedButton btn = new LightedButton(color, false, true, 1, i - 2);
|
||||
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)));
|
||||
Label lbl = new Label("->", color);
|
||||
ind.setX(0);
|
||||
ind.setY(i / 16F);
|
||||
|
@ -82,27 +75,28 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
components.add(lbl);
|
||||
components.add(btn);
|
||||
}
|
||||
for (PanelComponent pc:components) {
|
||||
pc.setPanel(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
for (PanelComponent pc : components) {
|
||||
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;
|
||||
for (PanelComponent pc : components) {
|
||||
pc.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetworkAndInit(ControlPanelNetwork newNet) {
|
||||
super.setNetworkAndInit(newNet);
|
||||
for (PanelComponent pc : components) {
|
||||
pc.setNetwork(newNet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
writeToItemNBT(out, false);
|
||||
|
@ -113,13 +107,13 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
readFromItemNBT(in);
|
||||
components.setFacing(EnumFacing.getHorizontal(in.getInteger("facing")));
|
||||
components.setTop(EnumFacing.getFront(in.getInteger("top")));
|
||||
components.setFacing(EnumFacing.byHorizontalIndex(in.getInteger("facing")));
|
||||
components.setTop(EnumFacing.byIndex(in.getInteger("top")));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getTileDrop(@Nonnull EntityPlayer player, @Nonnull IBlockState state) {
|
||||
public ItemStack getTileDrop(@Nullable EntityPlayer player, @Nonnull IBlockState state) {
|
||||
NBTTagCompound ret = new NBTTagCompound();
|
||||
writeToItemNBT(ret, true);
|
||||
ItemStack retStack = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
|
||||
|
@ -138,7 +132,17 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
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;
|
||||
|
@ -154,6 +158,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
nbt.setTag("components", comps);
|
||||
nbt.setFloat("height", components.getHeight());
|
||||
nbt.setFloat("angle", components.getAngle());
|
||||
nbt.setTag("texture", components.getTextureSource().serializeNBT());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -226,9 +231,9 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
Matrix4 mat = components.getPanelTopTransformInverse();
|
||||
PanelComponent retPc = null;
|
||||
RayTraceResult retRay = null;
|
||||
Vec3d playerPosRelative = player.getPositionVector().addVector(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
|
||||
Vec3d playerPosRelative = player.getPositionVector().add(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
|
||||
Vec3d playerPosTransformed = mat.apply(playerPosRelative);
|
||||
Vec3d hitRel = hitAbs ? hitVec.addVector(-pos.getX(), -pos.getY(), -pos.getZ()) : hitVec;
|
||||
Vec3d hitRel = hitAbs ? hitVec.add(-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;
|
||||
|
@ -281,53 +286,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
|
||||
public void interactServer(Vec3d hitRelative, int pcId, EntityPlayerMP player) {
|
||||
if (pcId >= 0 && pcId < components.size()) {
|
||||
components.get(pcId).interactWith(hitRelative, this, player);
|
||||
components.get(pcId).interactWith(hitRelative, 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,31 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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;
|
||||
|
@ -118,7 +115,12 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
|
|||
}
|
||||
}
|
||||
if (valid) {
|
||||
NBTTagCompound panelNBT = new NBTTagCompound();
|
||||
NBTTagCompound panelNBT;
|
||||
if (inv.hasTagCompound()) {
|
||||
panelNBT = inv.getTagCompound().copy();
|
||||
} else {
|
||||
panelNBT = new NBTTagCompound();
|
||||
}
|
||||
writeToItemNBT(panelNBT, true);
|
||||
ItemStack panel = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
|
||||
panel.setTagCompound(panelNBT);
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* 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.blocks.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.blocks.INetGUI;
|
||||
import malte0811.industrialwires.controlpanel.ControlPanelNetwork;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ITickable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class TileEntityRSPanel extends TileEntityGeneralCP implements INetGUI, ITickable {
|
||||
protected byte[] out = new byte[16];
|
||||
private boolean dirty = true;
|
||||
private byte[] currInput = new byte[16];
|
||||
private final ControlPanelNetwork.RSChannel[] channels = new ControlPanelNetwork.RSChannel[16];
|
||||
private int controller = 0;
|
||||
|
||||
|
||||
{
|
||||
for (int i = 0; i < 16; i++) {
|
||||
currInput[i] = -1;
|
||||
}
|
||||
updateChannelsArray();
|
||||
}
|
||||
|
||||
private void updateChannelsArray() {
|
||||
if (world == null || !world.isRemote) {
|
||||
panelNetwork.removeIOFor(this);
|
||||
for (byte i = 0; i < 16; i++) {
|
||||
channels[i] = new ControlPanelNetwork.RSChannel(controller, i);
|
||||
}
|
||||
setNetworkAndInit(panelNetwork);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (dirty) {
|
||||
updateOutput();
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
nbt.setByteArray("out", this.out);
|
||||
nbt.setByteArray("in", this.currInput);
|
||||
nbt.setInteger("rsId", controller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
if (nbt.hasKey("out") && nbt.getByteArray("out").length == 16) {
|
||||
out = nbt.getByteArray("out");
|
||||
}
|
||||
if (nbt.hasKey("in") && nbt.getByteArray("in").length == 16) {
|
||||
currInput = nbt.getByteArray("in");
|
||||
}
|
||||
controller = nbt.getInteger("rsId");
|
||||
updateChannelsArray();
|
||||
}
|
||||
|
||||
protected void markRSDirty() {
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
protected void onInputChanged(byte[] newIn) {
|
||||
if (!Arrays.equals(currInput, newIn)) {
|
||||
ControlPanelNetwork.RSChannelState[] newStates = new ControlPanelNetwork.RSChannelState[16];
|
||||
for (byte i = 0; i < 16; i++) {
|
||||
if (newIn[i]>out[i]) {
|
||||
newStates[i] = new ControlPanelNetwork.RSChannelState(channels[i], newIn[i]);
|
||||
} else {
|
||||
newStates[i] = new ControlPanelNetwork.RSChannelState(channels[i], (byte) 0);
|
||||
}
|
||||
}
|
||||
panelNetwork.setOutputs(this, newStates);
|
||||
currInput = Arrays.copyOf(newIn, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetworkAndInit(ControlPanelNetwork newNet) {
|
||||
super.setNetworkAndInit(newNet);
|
||||
Consumer<ControlPanelNetwork.RSChannelState> listener = state -> {
|
||||
if (out[state.getColor()] != state.getStrength()) {
|
||||
out[state.getColor()] = state.getStrength();
|
||||
dirty = true;
|
||||
}
|
||||
};
|
||||
panelNetwork.addListener(this, listener, channels);
|
||||
byte[] oldIn = currInput;
|
||||
currInput = new byte[16];
|
||||
onInputChanged(oldIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(NBTTagCompound nbt, EntityPlayer p) {
|
||||
if (nbt.hasKey("rsId")) {
|
||||
controller = nbt.getInteger("rsId");
|
||||
markDirty();
|
||||
panelNetwork.removeIOFor(this);
|
||||
setNetworkAndInit(panelNetwork);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
updateChannelsArray();
|
||||
}
|
||||
}
|
||||
|
||||
public int getRsId() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
||||
protected abstract void updateOutput();
|
||||
|
||||
protected abstract void updateInput();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
if (!world.isRemote) {
|
||||
updateInput();
|
||||
updateOutput();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
/*
|
||||
* 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.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.WireType;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.redstone.IRedstoneConnector;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.redstone.RedstoneWireNetwork;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.IBlockBoundsIW;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
|
||||
import static blusunrize.immersiveengineering.api.energy.wires.WireType.REDSTONE_CATEGORY;
|
||||
|
||||
public class TileEntityRSPanelIE extends TileEntityRSPanel
|
||||
implements IRedstoneConnector, IEBlockInterfaces.IDirectionalTile, IBlockBoundsIW {
|
||||
private EnumFacing facing = EnumFacing.NORTH;
|
||||
@Nonnull
|
||||
private RedstoneWireNetwork wireNetwork = new RedstoneWireNetwork().add(this);
|
||||
private boolean hasConn = false;
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
super.writeNBT(nbt, updatePacket);
|
||||
nbt.setBoolean("hasConn", hasConn);
|
||||
nbt.setInteger("facing", facing.getIndex());
|
||||
if (updatePacket) {
|
||||
writeConnsToNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
super.readNBT(nbt, updatePacket);
|
||||
if (nbt.hasKey("connectionList", Constants.NBT.TAG_LIST)) {
|
||||
loadConnsFromNBT(nbt);
|
||||
}
|
||||
hasConn = nbt.getBoolean("hasConn");
|
||||
facing = EnumFacing.VALUES[nbt.getInteger("facing")];
|
||||
aabb = null;
|
||||
}
|
||||
|
||||
//Copied from IE (TileEntityImmersiveConnectable)
|
||||
private void loadConnsFromNBT(NBTTagCompound nbt) {
|
||||
if (world != null && world.isRemote && !Minecraft.getMinecraft().isSingleplayer() && nbt != null) {
|
||||
NBTTagList connectionList = nbt.getTagList("connectionList", Constants.NBT.TAG_COMPOUND);
|
||||
ImmersiveNetHandler.INSTANCE.clearConnectionsOriginatingFrom(Utils.toCC(this), world);
|
||||
for (int i = 0; i < connectionList.tagCount(); i++) {
|
||||
NBTTagCompound conTag = connectionList.getCompoundTagAt(i);
|
||||
ImmersiveNetHandler.Connection con = ImmersiveNetHandler.Connection.readFromNBT(conTag);
|
||||
if (con != null) {
|
||||
ImmersiveNetHandler.INSTANCE.addConnection(world, Utils.toCC(this), con);
|
||||
} else
|
||||
IndustrialWires.logger.error("CLIENT read connection as null from {}", nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeConnsToNBT(NBTTagCompound nbt) {
|
||||
if (world != null && !world.isRemote && nbt != null) {
|
||||
NBTTagList connectionList = new NBTTagList();
|
||||
Set<ImmersiveNetHandler.Connection> conL = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(this));
|
||||
if (conL != null)
|
||||
for (ImmersiveNetHandler.Connection con : conL)
|
||||
connectionList.appendTag(con.writeToNBT());
|
||||
nbt.setTag("connectionList", connectionList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateOutput() {
|
||||
wireNetwork.updateValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateInput() {
|
||||
updateInput(wireNetwork.channelValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(@Nonnull RedstoneWireNetwork net) {
|
||||
wireNetwork = net;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public RedstoneWireNetwork getNetwork() {
|
||||
return wireNetwork;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange() {
|
||||
onInputChanged(wireNetwork.channelValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInput(byte[] currIn) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
currIn[i] = (byte) Math.max(currIn[i], out[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnergyOutput() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int outputEnergy(int amount, boolean simulate, int energyType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getConnectionMaster(@Nullable WireType wire, TargetingInfo target) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType wire, TargetingInfo targetingInfo, Vec3i offset) {
|
||||
return REDSTONE_CATEGORY.equals(wire.getCategory()) && !hasConn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectCable(WireType wireType, TargetingInfo targetingInfo, IImmersiveConnectable other) {
|
||||
hasConn = true;
|
||||
RedstoneWireNetwork.updateConnectors(pos, world, wireNetwork);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WireType getCableLimiter(TargetingInfo targetingInfo) {
|
||||
return WireType.REDSTONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowEnergyToPass(ImmersiveNetHandler.Connection connection) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCable(ImmersiveNetHandler.Connection connection) {
|
||||
hasConn = false;
|
||||
wireNetwork.removeFromNetwork(this);
|
||||
this.markDirty();
|
||||
if (world != null) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection connection) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
double conRadius = connection.cableType.getRenderDiameter() / 2;
|
||||
return new Vec3d(.5 - conRadius * side.getXOffset(), .5 - conRadius * side.getYOffset(), .5 - conRadius * side.getZOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getConnectorWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
if (world.isRemote && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||
ImmersiveNetHandler.INSTANCE.clearAllConnectionsFor(pos, world, this, false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* 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.blocks.controlpanel;
|
||||
|
||||
import malte0811.industrialwires.compat.Compat;
|
||||
import malte0811.industrialwires.compat.CompatCapabilities.Charset;
|
||||
import mrtjp.projectred.api.IBundledTile;
|
||||
import mrtjp.projectred.api.ProjectRedAPI;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Optional.Interface(iface = "mrtjp.projectred.api.IBundledTile", modid = ProjectRedAPI.modIDCore)
|
||||
public class TileEntityRSPanelOthers extends TileEntityRSPanel implements IBundledTile {
|
||||
|
||||
@Override
|
||||
public boolean canConnectBundled(int i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBundledSignal(int side) {
|
||||
byte[] ret = new byte[16];
|
||||
for (int i = 0;i<16;i++) {
|
||||
ret[i] = (byte) (17*out[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInput() {
|
||||
byte[] data = new byte[16];
|
||||
for (EnumFacing f:EnumFacing.VALUES) {
|
||||
byte[] tmp = Compat.getBundledRS.run(world, pos, f);
|
||||
if (tmp!=null) {
|
||||
for (int i = 0; i<16; i++) {
|
||||
if (tmp[i]>data[i]) {
|
||||
data[i] = tmp[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onInputChanged(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateOutput() {
|
||||
Compat.updateBundledRS.run(world, pos, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability==Charset.EMITTER_CAP) {
|
||||
return Charset.EMITTER_CAP.cast(()->Arrays.copyOf(out, 16));
|
||||
} else if (capability==Charset.RECEIVER_CAP) {
|
||||
return Charset.RECEIVER_CAP.cast(this::updateInput);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability==Charset.EMITTER_CAP||capability==Charset.RECEIVER_CAP;
|
||||
}
|
||||
}
|
|
@ -1,22 +1,19 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks.controlpanel;
|
||||
package malte0811.industrialwires.blocks.controlpanel;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
|
@ -1,26 +1,22 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks.converter;
|
||||
package malte0811.industrialwires.blocks.converter;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
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;
|
||||
|
@ -28,7 +24,6 @@ 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;
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* 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.blocks.converter;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
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;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockMechanicalMB extends BlockIWMultiblock implements IMetaEnum {
|
||||
public static final PropertyEnum<MechanicalMBBlockType> TYPE = PropertyEnum.create("type", MechanicalMBBlockType.class);
|
||||
public static final String NAME = "mech_mb";
|
||||
public BlockMechanicalMB() {
|
||||
super(Material.IRON, NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) {
|
||||
//NOP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getProperties() {
|
||||
return new IProperty[] {
|
||||
IEProperties.FACING_HORIZONTAL, TYPE
|
||||
};
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
BlockStateContainer base = super.createBlockState();
|
||||
return new ExtendedBlockState(this, base.getProperties().toArray(new IProperty[0]), new IUnlistedProperty[]{
|
||||
IWProperties.MB_SIDES
|
||||
});
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getExtendedState(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
state = super.getExtendedState(state, world, pos);
|
||||
if (te instanceof TileEntityMechMB)
|
||||
state = ((TileEntityMechMB) te).getExtState(state);
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
|
||||
return new TileEntityMechMB();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(TYPE).ordinal();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(TYPE, MechanicalMBBlockType.VALUES[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getValues() {
|
||||
return TYPE.getAllowedValues().toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) {
|
||||
if ((id&255)==255) {
|
||||
IBlockState s = worldIn.getBlockState(pos);
|
||||
worldIn.notifyBlockUpdate(pos, s, s, 3);
|
||||
if (param>=0) {
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (te instanceof TileEntityMechMB && !((TileEntityMechMB) te).isLogicDummy()) {
|
||||
int[] offsets = ((TileEntityMechMB) te).offsets;
|
||||
if (offsets!=null && param<offsets.length) {
|
||||
BlockPos otherPos = pos.offset(((TileEntityMechMB) te).getFacing(), -offsets[param]);
|
||||
s = worldIn.getBlockState(otherPos);
|
||||
worldIn.notifyBlockUpdate(otherPos, s, s, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.eventReceived(state, worldIn, pos, id, param);
|
||||
}
|
||||
}
|
|
@ -1,21 +1,18 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks.converter;
|
||||
package malte0811.industrialwires.blocks.converter;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
|
@ -1,39 +1,39 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks;
|
||||
package malte0811.industrialwires.blocks.converter;
|
||||
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
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;
|
||||
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();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
}
|
|
@ -1,30 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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;
|
||||
|
@ -33,12 +30,15 @@ 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,7 +52,8 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
}
|
||||
int max = MechConversion.maxIfToMech;
|
||||
boolean dirty = false;
|
||||
if (rotBuffer < bufferMax && energy.extractEnergy(max, true) > 0) {
|
||||
if (rotBuffer < 2 * MechConversion.maxIfToMech * ConversionUtil.rotPerIf()
|
||||
&& energy.extractEnergy(max, true) > 0) {
|
||||
int extracted = energy.extractEnergy(max, false);
|
||||
rotBuffer += extracted * ConversionUtil.rotPerIf() * MechConversion.ifMotorEfficiency;
|
||||
dirty = true;
|
||||
|
@ -71,19 +72,19 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
dir = EnumFacing.VALUES[in.getByte(DIR_TAG)];
|
||||
energy.readFromNBT(in.getCompoundTag(ENERGY_TAG));
|
||||
dir = EnumFacing.VALUES[in.getByte(DIRECTION)];
|
||||
energy.readFromNBT(in.getCompoundTag(ENERGY));
|
||||
receiver = null;
|
||||
rotBuffer = in.getDouble(BUFFER_TAG);
|
||||
rotBuffer = in.getDouble(BUFFER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(DIR_TAG, (byte) dir.getIndex());
|
||||
out.setByte(DIRECTION, (byte) dir.getIndex());
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
energy.writeToNBT(nbt);
|
||||
out.setTag(ENERGY_TAG, nbt);
|
||||
out.setDouble(BUFFER_TAG, rotBuffer);
|
||||
out.setTag(ENERGY, nbt);
|
||||
out.setDouble(BUFFER, rotBuffer);
|
||||
}
|
||||
|
||||
// Flux energy
|
||||
|
@ -150,11 +151,14 @@ 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)) {
|
||||
return (T) new EnergyAdapter(this, facing);
|
||||
if (!energies.containsKey(facing))
|
||||
energies.put(facing, new EnergyAdapter(this, facing));
|
||||
return CapabilityEnergy.ENERGY.cast(energies.get(facing));
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
|
@ -1,28 +1,25 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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;
|
||||
|
@ -32,13 +29,14 @@ 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 {
|
||||
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;
|
||||
private EnumFacing dir = EnumFacing.DOWN;
|
||||
private int kinBuffer = 0;
|
||||
private BlockPos to;
|
||||
private BlockPos from;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
@ -52,14 +50,15 @@ 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(kinBufMax - kinBuffer, sourceMax);
|
||||
int draw = Math.min(2 * MechConversion.maxKinToRot - 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(maxInsert, ConversionUtil.rotPerKin() * kinBuffer);
|
||||
double out = Math.min(ConversionUtil.rotPerKin() * MechConversion.maxKinToRot,
|
||||
ConversionUtil.rotPerKin() * kinBuffer);
|
||||
((IRotationAcceptor) teTo).inputRotation(out, dir);
|
||||
kinBuffer -= out * ConversionUtil.kinPerRot();
|
||||
}
|
||||
|
@ -68,14 +67,14 @@ public class TileEntityMechICtoIE extends TileEntityIWBase implements IDirection
|
|||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(DIR_TAG, (byte) dir.getIndex());
|
||||
out.setInteger(BUFFER_TAG, kinBuffer);
|
||||
out.setByte(DIRECTION, (byte) dir.getIndex());
|
||||
out.setInteger(BUFFER, kinBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
dir = EnumFacing.VALUES[in.getByte(DIR_TAG)];
|
||||
kinBuffer = in.getInteger(BUFFER_TAG);
|
||||
dir = EnumFacing.VALUES[in.getByte(DIRECTION)];
|
||||
kinBuffer = in.getInteger(BUFFER);
|
||||
to = null;
|
||||
from = null;
|
||||
}
|
|
@ -1,50 +1,49 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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 {
|
||||
EnumFacing dir = EnumFacing.DOWN;
|
||||
double rotBuffer = 0;
|
||||
private final double rotBufMax = 2 * MechConversion.maxRotToKin;
|
||||
private final int maxOutput = (int) (ConversionUtil.kinPerRot() * MechConversion.maxRotToKin);
|
||||
private EnumFacing dir = EnumFacing.DOWN;
|
||||
private double rotBuffer = 0;
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(DIR_TAG, (byte) dir.getIndex());
|
||||
out.setDouble(BUFFER_TAG, rotBuffer);
|
||||
out.setByte(DIRECTION, (byte) dir.getIndex());
|
||||
out.setDouble(BUFFER, rotBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
dir = EnumFacing.VALUES[in.getByte(DIR_TAG)];
|
||||
rotBuffer = in.getDouble(BUFFER_TAG);
|
||||
dir = EnumFacing.VALUES[in.getByte(DIRECTION)];
|
||||
rotBuffer = in.getDouble(BUFFER);
|
||||
}
|
||||
|
||||
// Directional
|
||||
|
@ -75,23 +74,36 @@ public class TileEntityMechIEtoIC extends TileEntityIWBase implements IDirection
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int maxrequestkineticenergyTick(EnumFacing enumFacing) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//IC2 kinetic
|
||||
@Override
|
||||
public int maxrequestkineticenergyTick(EnumFacing f) {
|
||||
public int getConnectionBandwidth(EnumFacing f) {
|
||||
if (f == dir) {
|
||||
return maxOutput;
|
||||
return (int) (ConversionUtil.kinPerRot() * rotBuffer);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int requestkineticenergy(EnumFacing f, int requested) {
|
||||
@Deprecated
|
||||
public int requestkineticenergy(EnumFacing enumFacing, int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawKineticEnergy(EnumFacing f, int requested, boolean simulate) {
|
||||
if (f == dir) {
|
||||
int stored = (int) (ConversionUtil.kinPerRot() * rotBuffer);
|
||||
int out = Math.min(maxOutput, stored);
|
||||
out = Math.min(requested, out);
|
||||
rotBuffer -= out * ConversionUtil.rotPerKin();
|
||||
int out = Math.min(requested, stored);
|
||||
if (!simulate) {
|
||||
rotBuffer -= out * ConversionUtil.rotPerKin();
|
||||
}
|
||||
return (int) (out * MechConversion.rotToKinEfficiency);
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -102,7 +114,7 @@ public class TileEntityMechIEtoIC extends TileEntityIWBase implements IDirection
|
|||
@Override
|
||||
public void inputRotation(double rotation, @Nonnull EnumFacing side) {
|
||||
if (side == dir) {
|
||||
rotBuffer = Math.min(rotBufMax, rotBuffer + rotation);
|
||||
rotBuffer = Math.min(Math.max(rotBuffer, rotation), maxRotToKin);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,704 @@
|
|||
/*
|
||||
* 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.blocks.converter;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IPlayerInteraction;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IRedstoneOutput;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import com.google.common.collect.MapMaker;
|
||||
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.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.IBlockBoundsIW.IBlockBoundsDirectional;
|
||||
import malte0811.industrialwires.blocks.ISyncReceiver;
|
||||
import malte0811.industrialwires.blocks.TileEntityIWMultiblock;
|
||||
import malte0811.industrialwires.compat.Compat;
|
||||
import malte0811.industrialwires.mech_mb.*;
|
||||
import malte0811.industrialwires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialwires.util.LocalSidedWorld;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
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.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
import static blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0.HEAVY_ENGINEERING;
|
||||
import static malte0811.industrialwires.IEObjects.blockMetalDecoration0;
|
||||
import static malte0811.industrialwires.IndustrialWires.MMB_BREAKING;
|
||||
import static malte0811.industrialwires.mech_mb.EUCapability.ENERGY_IC2;
|
||||
import static malte0811.industrialwires.util.MiscUtils.getOffset;
|
||||
import static malte0811.industrialwires.util.MiscUtils.offset;
|
||||
import static malte0811.industrialwires.util.NBTKeys.*;
|
||||
|
||||
@net.minecraftforge.fml.common.Optional.InterfaceList({
|
||||
@net.minecraftforge.fml.common.Optional.Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "ic2"),
|
||||
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "ic2")
|
||||
})
|
||||
public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickable, ISyncReceiver,
|
||||
IEnergySource, IEnergySink, IPlayerInteraction, IRedstoneOutput, IBlockBoundsDirectional {
|
||||
private static final double DECAY_BASE = Math.exp(Math.log(.95) / (60 * 60 * 20));
|
||||
public static final double TICK_ANGLE_PER_SPEED = 180 / 20 / Math.PI;
|
||||
private static final double SYNC_THRESHOLD = .95;
|
||||
private static final Map<BlockPos, TileEntityMechMB> CLIENT_MASTER_BY_POS = new MapMaker().weakValues().makeMap();
|
||||
public MechMBPart[] mechanical = null;
|
||||
int[] offsets = null;
|
||||
|
||||
private int[][] electricalStartEnd = null;
|
||||
|
||||
public MechEnergy energyState;
|
||||
private double lastSyncedSpeed = 0;
|
||||
private double decay;
|
||||
public double angle;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<BakedQuad> rotatingModel;
|
||||
private boolean firstTick = true;
|
||||
// To allow changing the MB structure later on without resulting in dupes/conversion
|
||||
private int structureVersion = 0;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
ApiUtils.checkForNeedlessTicking(this);
|
||||
if (firstTick && !world.isRemote) {
|
||||
Compat.loadIC2Tile.accept(this);
|
||||
firstTick = false;
|
||||
}
|
||||
if (isLogicDummy() || mechanical == null || mechanical.length==0) {
|
||||
return;
|
||||
}
|
||||
if (world.isRemote) {
|
||||
angle += energyState.getSpeed() * TICK_ANGLE_PER_SPEED;
|
||||
angle %= 360;
|
||||
if (firstTick) {
|
||||
CLIENT_MASTER_BY_POS.put(pos, this);
|
||||
}
|
||||
if (energyState.clientUpdate()||firstTick) {
|
||||
IndustrialWires.proxy.updateMechMBTurningSound(this, energyState);
|
||||
TileEntity otherEnd = Utils.getExistingTileEntity(world, pos.offset(facing, -offsets[mechanical.length]));
|
||||
if (otherEnd instanceof TileEntityMechMB) {
|
||||
IndustrialWires.proxy.updateMechMBTurningSound((TileEntityMechMB) otherEnd, energyState);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Mechanical
|
||||
for (MechMBPart part : mechanical) {
|
||||
part.createMEnergy(energyState);
|
||||
}
|
||||
double requestSum = 0;
|
||||
IdentityHashMap<MechMBPart, Double> individualRequests = new IdentityHashMap<>();
|
||||
for (MechMBPart part : mechanical) {
|
||||
double eForPart = part.requestMEnergy(energyState);
|
||||
requestSum += eForPart;
|
||||
individualRequests.put(part, eForPart);
|
||||
}
|
||||
double availableEnergy = energyState.getEnergy() / 5;//prevent energy transmission without movement
|
||||
double factor = Math.min(availableEnergy / requestSum, 1);
|
||||
energyState.extractEnergy(Math.min(requestSum, availableEnergy));
|
||||
for (MechMBPart part : mechanical) {
|
||||
part.insertMEnergy(factor * individualRequests.get(part));
|
||||
}
|
||||
Set<MechMBPart> failed = new HashSet<>();
|
||||
for (MechMBPart part : mechanical) {
|
||||
if (energyState.getSpeed() > part.getMaxSpeed()) {
|
||||
failed.add(part);
|
||||
}
|
||||
}
|
||||
if (!failed.isEmpty()) {
|
||||
disassemble(failed);
|
||||
return;
|
||||
}
|
||||
|
||||
//Electrical
|
||||
for (int[] section : electricalStartEnd) {
|
||||
final int sectionLength = section[1] - section[0];
|
||||
double[] available = new double[sectionLength];
|
||||
Waveform[] availableWf = new Waveform[sectionLength];
|
||||
boolean hasEnergy = false;
|
||||
Set<Waveform> availableWaveforms = new HashSet<>();
|
||||
for (int i = section[0]; i < section[1]; i++) {
|
||||
IMBPartElectric electricalComp = ((IMBPartElectric) mechanical[i]);
|
||||
Waveform localWf = electricalComp.getProduced(energyState).getForSpeed(energyState.getSpeed());
|
||||
availableWf[i - section[0]] = localWf;
|
||||
if (!localWf.isEnergyWaveform()) {
|
||||
continue;
|
||||
}
|
||||
double availableLocal = electricalComp.getAvailableEEnergy(energyState);
|
||||
available[i - section[0]] = availableLocal;
|
||||
availableWaveforms.add(localWf);
|
||||
if (availableLocal > 0) {
|
||||
hasEnergy = true;
|
||||
}
|
||||
}
|
||||
if (hasEnergy) {
|
||||
List<Waveform> availableWfList = new ArrayList<>(availableWaveforms);
|
||||
double[][] requested = new double[availableWfList.size()][sectionLength];
|
||||
for (int i = 0; i < requested.length; i++) {
|
||||
Waveform wf = availableWfList.get(i);
|
||||
if (wf.isEnergyWaveform()) {
|
||||
for (int j = 0; j < sectionLength; j++) {
|
||||
requested[i][j] = ((IMBPartElectric) mechanical[j + section[0]]).requestEEnergy(wf, energyState);
|
||||
}
|
||||
}
|
||||
}
|
||||
int maxId = -1;
|
||||
double maxTransferred = 0;
|
||||
for (int i = 0; i < requested.length; i++) {
|
||||
Waveform wf = availableWfList.get(i);
|
||||
double transferred = transferElectric(section, Arrays.copyOf(available, sectionLength), availableWf, wf,
|
||||
Arrays.copyOf(requested[i], sectionLength), true);
|
||||
if (transferred > maxTransferred) {
|
||||
maxTransferred = transferred;
|
||||
maxId = i;
|
||||
}
|
||||
}
|
||||
if (maxId < 0) {
|
||||
double[] availablePerWf = new double[availableWaveforms.size()];
|
||||
for (int i = 0; i < availableWf.length; i++) {
|
||||
if (availableWf[i].isEnergyWaveform()) {
|
||||
availablePerWf[availableWfList.indexOf(availableWf[i])] += available[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < availablePerWf.length; i++) {
|
||||
if (availablePerWf[i] > 0 && (maxId < 0 || availablePerWf[maxId] < availablePerWf[i])) {
|
||||
maxId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (maxId >= 0) {
|
||||
transferElectric(section, available, availableWf, availableWfList.get(maxId), requested[maxId], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//General
|
||||
energyState.decaySpeed(decay);
|
||||
markDirty();
|
||||
if (lastSyncedSpeed < energyState.getSpeed() * SYNC_THRESHOLD || lastSyncedSpeed > energyState.getSpeed() / SYNC_THRESHOLD) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setDouble(SPEED, energyState.getSpeed());
|
||||
IndustrialWires.packetHandler.sendToDimension(new MessageTileSyncIW(this, nbt), world.provider.getDimension());
|
||||
lastSyncedSpeed = energyState.getSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorld(@Nonnull World worldIn) {
|
||||
super.setWorld(worldIn);
|
||||
if (!isLogicDummy()) {
|
||||
int offset = 1;
|
||||
for (MechMBPart part : mechanical) {
|
||||
part.world.setWorld(world);
|
||||
part.world.setOrigin(offset(pos, facing, mirrored, 0, -offset, 0));
|
||||
offset += part.getLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IBlockState getExtState(IBlockState in) {
|
||||
TileEntityMechMB master = CLIENT_MASTER_BY_POS.get(pos.subtract(offset));
|
||||
if (master==null)
|
||||
return in;
|
||||
Vec3i offsetDirectional = getOffsetDir();
|
||||
int id = getPart(offsetDirectional.getZ(), master);
|
||||
if (id < 0) {
|
||||
return in;
|
||||
}
|
||||
MechMBPart part = master.mechanical[id];
|
||||
return part.getExtState(in);
|
||||
}
|
||||
|
||||
//return value is maximized to choose the waveform to use
|
||||
private double transferElectric(int[] section, double[] available, Waveform[] availableWf, Waveform waveform,
|
||||
double[] requested, boolean simulate) {
|
||||
double totalAvailable = 0;
|
||||
double totalRequested = 0;
|
||||
for (int i = 0; i < available.length; i++) {
|
||||
if (!availableWf[i].equals(waveform)) {
|
||||
available[i] = 0;
|
||||
}
|
||||
totalRequested += requested[i];
|
||||
}
|
||||
for (int i = 0; i < available.length; i++) {
|
||||
if (available[i]>0) {
|
||||
available[i] = Math.min(available[i], totalRequested-requested[i]);
|
||||
totalAvailable += available[i];
|
||||
}
|
||||
}
|
||||
double[] ins = new double[section[1]-section[0]];
|
||||
double[] extracted = new double[section[1]-section[0]];
|
||||
if (totalAvailable>0) {
|
||||
for (int i = section[0]; i < section[1]; i++) {
|
||||
int i0 = i - section[0];
|
||||
double otherRequests = totalRequested - requested[i0];
|
||||
double extractFactor = Math.min(1, otherRequests / totalAvailable);
|
||||
double extr = available[i0] * extractFactor;
|
||||
if (extr == 0) {
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < section[1] - section[0]; j++) {
|
||||
if (j != i0) {
|
||||
ins[j] += extr * (requested[j] / otherRequests);
|
||||
}
|
||||
}
|
||||
extracted[i0] = extr;
|
||||
if (!simulate) {
|
||||
IMBPartElectric electric = (IMBPartElectric) mechanical[i];
|
||||
electric.extractEEnergy(extr, energyState);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!simulate) {
|
||||
for (int i = section[0]; i < section[1]; i++) {
|
||||
int i0 = i - section[0];
|
||||
IMBPartElectric electric = (IMBPartElectric) mechanical[i];
|
||||
electric.insertEEnergy(ins[i0], waveform, energyState);
|
||||
}
|
||||
}
|
||||
double totalTransf = 0;
|
||||
for (int i = 0; i < section[1] - section[0]; i++) {
|
||||
totalTransf += Math.abs(ins[i]-extracted[i]);
|
||||
}
|
||||
return totalTransf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
super.writeNBT(out, updatePacket);
|
||||
if (mechanical != null) {
|
||||
NBTTagList mechParts = new NBTTagList();
|
||||
for (MechMBPart part : mechanical) {
|
||||
mechParts.appendTag(MechMBPart.toNBT(part));
|
||||
}
|
||||
out.setTag(PARTS, mechParts);
|
||||
out.setDouble(SPEED, energyState.getSpeed());
|
||||
}
|
||||
out.setInteger(VERSION, structureVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
super.readNBT(in, updatePacket);
|
||||
if (in.hasKey(PARTS, Constants.NBT.TAG_LIST)) {
|
||||
NBTTagList mechParts = in.getTagList(PARTS, Constants.NBT.TAG_COMPOUND);
|
||||
MechMBPart[] mech = new MechMBPart[mechParts.tagCount()];
|
||||
int offset = 1;
|
||||
for (int i = 0; i < mechParts.tagCount(); i++) {
|
||||
mech[i] = MechMBPart.fromNBT(mechParts.getCompoundTagAt(i),
|
||||
new LocalSidedWorld(world, offset(pos, facing, mirrored, 0, -offset, 0), facing.getOpposite(), mirrored));
|
||||
offset += mech[i].getLength();
|
||||
}
|
||||
setMechanical(mech, in.getDouble(SPEED));
|
||||
}
|
||||
structureVersion = in.getInteger(VERSION);
|
||||
rBB = null;
|
||||
aabb = null;
|
||||
}
|
||||
|
||||
public void setMechanical(MechMBPart[] mech, double speed) {
|
||||
mechanical = mech;
|
||||
offsets = new int[mechanical.length+1];
|
||||
double weight = 0;
|
||||
int offset = 1;
|
||||
List<int[]> electrical = new ArrayList<>();
|
||||
int lastEStart = -1;
|
||||
for (int i = 0; i < mech.length; i++) {
|
||||
offsets[i] = offset;
|
||||
weight += mechanical[i].getInertia();
|
||||
offset += mechanical[i].getLength();
|
||||
if (lastEStart < 0 && mechanical[i] instanceof IMBPartElectric) {
|
||||
lastEStart = i;
|
||||
} else if (lastEStart >= 0 && !(mechanical[i] instanceof IMBPartElectric)) {
|
||||
electrical.add(new int[]{lastEStart, i});
|
||||
lastEStart = -1;
|
||||
}
|
||||
}
|
||||
offsets[mechanical.length] = offset;
|
||||
if (lastEStart >= 0) {
|
||||
electrical.add(new int[]{lastEStart, mechanical.length});
|
||||
}
|
||||
electricalStartEnd = electrical.toArray(new int[electrical.size()][]);
|
||||
decay = Math.pow(DECAY_BASE, mechanical.length);
|
||||
if (energyState!=null) {
|
||||
energyState.invalid = true;
|
||||
}
|
||||
energyState = new MechEnergy(weight, speed);
|
||||
}
|
||||
|
||||
private int getPart(int offset, TileEntityMechMB master) {
|
||||
if (offset == 0) {
|
||||
return -1;
|
||||
}
|
||||
int pos = 1;
|
||||
MechMBPart[] mechMaster = master.mechanical;
|
||||
if (mechMaster != null) {
|
||||
for (int i = 0, mechanical1Length = mechMaster.length; i < mechanical1Length; i++) {
|
||||
MechMBPart part = mechMaster[i];
|
||||
if (pos >= offset) {
|
||||
return i;
|
||||
}
|
||||
pos += part.getLength();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockPos getOrigin() {
|
||||
return pos;//Irrelevant, since this uses a custom disassembly method
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getOriginalBlock() {
|
||||
return Blocks.AIR.getDefaultState();//Irrelevant, the method below is used for pick block
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOriginalItem() {
|
||||
Vec3i offsetDirectional = getOffsetDir();
|
||||
TileEntityMechMB master = masterOr(this, this);
|
||||
int id = getPart(offsetDirectional.getZ(), master);
|
||||
if (id < 0) {
|
||||
return new ItemStack(blockMetalDecoration0, 1,
|
||||
BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.ordinal());
|
||||
}
|
||||
MechMBPart part = master.mechanical[id];
|
||||
BlockPos offsetPart = new BlockPos(offsetDirectional.getX(), offsetDirectional.getY(), offsetDirectional.getZ() - master.offsets[id]);
|
||||
return part.getOriginalItem(offsetPart);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onSync(NBTTagCompound nbt) {
|
||||
energyState.setTargetSpeed(nbt.getDouble(SPEED));
|
||||
}
|
||||
|
||||
private AxisAlignedBB rBB;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
if (rBB == null) {
|
||||
if (isLogicDummy()) {
|
||||
rBB = new AxisAlignedBB(pos, pos);
|
||||
} else {
|
||||
rBB = new AxisAlignedBB(offset(pos, facing, mirrored, -2, 0, -2),
|
||||
offset(pos, facing, mirrored, 2, -mechanical.length, 2));
|
||||
}
|
||||
}
|
||||
return rBB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
Vec3i offsetDirectional = getOffsetDir();
|
||||
TileEntityMechMB master = masterOr(this, this);
|
||||
int id = getPart(offsetDirectional.getZ(), master);
|
||||
if (id < 0) {
|
||||
return false;
|
||||
}
|
||||
MechMBPart part = master.mechanical[id];
|
||||
BlockPos offsetPart = new BlockPos(offsetDirectional.getX(), offsetDirectional.getY(), offsetDirectional.getZ() - master.offsets[id]);
|
||||
return part.hasCapability(capability, part.world.realToTransformed(facing), offsetPart);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
Vec3i offsetDirectional = getOffsetDir();
|
||||
TileEntityMechMB master = masterOr(this, this);
|
||||
|
||||
int id = getPart(offsetDirectional.getZ(), master);
|
||||
if (id < 0) {
|
||||
return null;
|
||||
}
|
||||
MechMBPart part = master.mechanical[id];
|
||||
BlockPos offsetPart = new BlockPos(offsetDirectional.getX(), offsetDirectional.getY(), offsetDirectional.getZ() - master.offsets[id]);
|
||||
return part.getCapability(capability, part.world.realToTransformed(facing), offsetPart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disassemble() {
|
||||
final double MIN_BREAK = .1;
|
||||
final double MIN_BREAK_BROKEN = .5;
|
||||
if (formed) {
|
||||
TileEntityMechMB master = master(this);
|
||||
if (master != null) {
|
||||
int partId = master.getPart(offset.getX(), master);
|
||||
MechMBPart broken = null;
|
||||
if (partId >= 0) {
|
||||
broken = master.mechanical[partId];
|
||||
}
|
||||
Set<MechMBPart> failed = new HashSet<>();
|
||||
for (MechMBPart part : master.mechanical) {
|
||||
if (master.energyState.getSpeed() > (part == broken ? MIN_BREAK_BROKEN : MIN_BREAK) * part.getMaxSpeed()) {
|
||||
failed.add(part);
|
||||
}
|
||||
}
|
||||
master.disassemble(failed);
|
||||
try {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
state.getBlock().getDrops(drops, world, pos, state, 0);
|
||||
world.setBlockToAir(pos);
|
||||
for (ItemStack s:drops) {
|
||||
Block.spawnAsEntity(world, pos, s);
|
||||
}
|
||||
} catch (Exception x) {
|
||||
x.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void disassemble(Set<MechMBPart> failed) {
|
||||
if (!world.isRemote && formed) {
|
||||
formed = false;
|
||||
world.setBlockState(pos,
|
||||
blockMetalDecoration0.getDefaultState().withProperty(blockMetalDecoration0.property, HEAVY_ENGINEERING));
|
||||
world.setBlockState(pos.down(),
|
||||
blockMetalDecoration0.getDefaultState().withProperty(blockMetalDecoration0.property, HEAVY_ENGINEERING));
|
||||
for (MechMBPart mech : mechanical) {
|
||||
if (failed.contains(mech)) {
|
||||
world.playSound(null, mech.world.getOrigin(), MMB_BREAKING, SoundCategory.BLOCKS, 1, 1);
|
||||
|
||||
mech.breakOnFailure(energyState);
|
||||
} else {
|
||||
mech.disassemble();
|
||||
}
|
||||
for (int l = 0;l<mech.getLength();l++) {
|
||||
short pattern = mech.getFormPattern(l);
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (((pattern >> i) & 1) != 0) {
|
||||
BlockPos pos = new BlockPos(i % 3 - 1, i / 3 - 1, -l);
|
||||
if (mech.world.getBlockState(pos).getBlock() == IndustrialWires.mechanicalMB) {
|
||||
mech.world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockPos otherEnd = offset(pos, facing.getOpposite(), mirrored, 0,
|
||||
offsets[mechanical.length], 0);
|
||||
world.setBlockState(otherEnd,
|
||||
blockMetalDecoration0.getDefaultState().withProperty(blockMetalDecoration0.property, HEAVY_ENGINEERING));
|
||||
world.setBlockState(otherEnd.down(),
|
||||
blockMetalDecoration0.getDefaultState().withProperty(blockMetalDecoration0.property, HEAVY_ENGINEERING));
|
||||
}
|
||||
}
|
||||
|
||||
private EUCapability.IC2EnergyHandler getIC2Cap() {
|
||||
return ENERGY_IC2 != null ? getCapability(ENERGY_IC2, null) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean emitsEnergyTo(IEnergyAcceptor output, EnumFacing side) {
|
||||
if (ENERGY_IC2 == null)
|
||||
return false;
|
||||
Vec3i offsetDirectional = getOffsetDir();
|
||||
TileEntityMechMB master = masterOr(this, this);
|
||||
int id = getPart(offsetDirectional.getZ(), master);
|
||||
if (id < 0) {
|
||||
return false;
|
||||
}
|
||||
MechMBPart part = master.mechanical[id];
|
||||
BlockPos offsetPart = new BlockPos(offsetDirectional.getX(), offsetDirectional.getY(), offsetDirectional.getZ() - master.offsets[id]);
|
||||
EUCapability.IC2EnergyHandler cap = part.getCapability(ENERGY_IC2, part.world.realToTransformed(side), offsetPart);
|
||||
return cap != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDemandedEnergy() {
|
||||
EUCapability.IC2EnergyHandler cap = getIC2Cap();
|
||||
return cap != null ? cap.getDemandedEnergy() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSinkTier() {
|
||||
EUCapability.IC2EnergyHandler cap = getIC2Cap();
|
||||
return cap != null ? cap.getEnergyTier() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy(EnumFacing enumFacing, double amount, double voltage) {
|
||||
EUCapability.IC2EnergyHandler cap = getIC2Cap();
|
||||
return cap != null ? cap.injectEnergy(enumFacing, amount, voltage) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(IEnergyEmitter input, EnumFacing side) {
|
||||
if (ENERGY_IC2 == null)
|
||||
return false;
|
||||
Vec3i offsetDirectional = getOffsetDir();
|
||||
TileEntityMechMB master = masterOr(this, this);
|
||||
int id = getPart(offsetDirectional.getZ(), master);
|
||||
if (id < 0) {
|
||||
return false;
|
||||
}
|
||||
MechMBPart part = master.mechanical[id];
|
||||
BlockPos offsetPart = new BlockPos(offsetDirectional.getX(), offsetDirectional.getY(), offsetDirectional.getZ() - master.offsets[id]);
|
||||
EUCapability.IC2EnergyHandler cap = part.getCapability(ENERGY_IC2, part.world.realToTransformed(side), offsetPart);
|
||||
return cap != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOfferedEnergy() {
|
||||
EUCapability.IC2EnergyHandler cap = getIC2Cap();
|
||||
return cap != null ? cap.getOfferedEnergy() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEnergy(double amount) {
|
||||
EUCapability.IC2EnergyHandler cap = getIC2Cap();
|
||||
if (cap != null) {
|
||||
cap.drawEnergy(amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceTier() {
|
||||
EUCapability.IC2EnergyHandler cap = getIC2Cap();
|
||||
return cap != null ? cap.getEnergyTier() : 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (!world.isRemote && !firstTick)
|
||||
Compat.unloadIC2Tile.accept(this);
|
||||
else if (world.isRemote)
|
||||
CLIENT_MASTER_BY_POS.remove(pos);
|
||||
firstTick = true;
|
||||
if (energyState!=null)
|
||||
energyState.invalid = true;
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
if (!world.isRemote && !firstTick)
|
||||
Compat.unloadIC2Tile.accept(this);
|
||||
else if (world.isRemote)
|
||||
CLIENT_MASTER_BY_POS.remove(pos);
|
||||
if (energyState!=null)
|
||||
energyState.invalid = true;
|
||||
firstTick = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interact(@Nonnull EnumFacing side, @Nonnull EntityPlayer player, @Nonnull EnumHand hand,
|
||||
@Nonnull ItemStack heldItem, float hitX, float hitY, float hitZ) {
|
||||
TileEntityMechMB master = masterOr(this, this);
|
||||
int id = getPart(getOffsetDir().getZ(), master);
|
||||
if (id >= 0) {
|
||||
MechMBPart part = master.mechanical[id];
|
||||
side = part.world.realToTransformed(side);
|
||||
int ret = part.interact(side, getOffsetDir().add(0, 0, - master.offsets[id]),
|
||||
player, hand, heldItem);
|
||||
if (ret>=0) {
|
||||
if ((ret&1)!=0) {
|
||||
IBlockState state = world.getBlockState(master.pos);
|
||||
world.notifyBlockUpdate(master.pos, state, state, 3);
|
||||
world.addBlockEvent(master.pos, state.getBlock(), 255, id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private BlockPos getOffsetDir() {
|
||||
BlockPos offset = getOffset(BlockPos.NULL_VECTOR, facing, mirrored, this.offset);
|
||||
return new BlockPos(offset.getX(), offset.getZ(), offset.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStrongRSOutput(@Nonnull IBlockState state, @Nonnull EnumFacing side) {
|
||||
TileEntityMechMB master = masterOr(this, this);
|
||||
int id = getPart(getOffsetDir().getZ(), master);
|
||||
if (id >= 0 && master.mechanical[id] instanceof IRedstoneOutput) {
|
||||
MechMBPart part = master.mechanical[id];
|
||||
return ((IRedstoneOutput) part).getStrongRSOutput(state,
|
||||
part.world.realToTransformed(side));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(@Nonnull IBlockState state, @Nonnull EnumFacing side) {
|
||||
TileEntityMechMB master = masterOr(this, this);
|
||||
int id = getPart(getOffsetDir().getZ(), master);
|
||||
if (id >= 0 && master.mechanical[id] instanceof IRedstoneOutput) {
|
||||
MechMBPart part = master.mechanical[id];
|
||||
return ((IRedstoneOutput) part).canConnectRedstone(state,
|
||||
part.world.realToTransformed(side));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBoxNoRot() {
|
||||
Vec3i offset = getOffsetDir();
|
||||
TileEntityMechMB master = masterOr(this, this);
|
||||
if (master==this&&!offset.equals(Vec3i.NULL_VECTOR))
|
||||
return new AxisAlignedBB(0, 0, 0, 0, 0, 0);
|
||||
int comp = getPart(offset.getZ(), master);
|
||||
if (comp < 0) {
|
||||
if (offset.getZ() == 0) {
|
||||
return new AxisAlignedBB(0, 0, .25, 1, 1, 1 + offset.getY() * .25);
|
||||
} else {
|
||||
return new AxisAlignedBB(0, 0, -offset.getY() * .25, 1, 1, .75);
|
||||
}
|
||||
}
|
||||
MechMBPart part = master.mechanical[comp];
|
||||
BlockPos offsetPart = new BlockPos(offset.getX(), offset.getY(), offset.getZ() - master.offsets[comp]);
|
||||
return part.getBoundingBox(offsetPart);
|
||||
}
|
||||
|
||||
public AxisAlignedBB aabb = null;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
if (aabb == null || aabb.minX==aabb.maxX)
|
||||
{
|
||||
aabb = IBlockBoundsDirectional.super.getBoundingBox();
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* 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.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
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;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockGeneralHV extends BlockIWBase implements IMetaEnum {
|
||||
public static final PropertyEnum<BlockTypes_GeneralHV> PROPERTY = PropertyEnum.create("type",
|
||||
BlockTypes_GeneralHV.class);
|
||||
public static final String NAME = "general_hv";
|
||||
|
||||
public BlockGeneralHV() {
|
||||
super(Material.IRON, NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getProperties() {
|
||||
return new IProperty[] {
|
||||
IEProperties.BOOLEANS[0], PROPERTY, IEProperties.FACING_HORIZONTAL
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTopSolid(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullBlock(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
state = super.getActualState(state, worldIn, pos);
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (te instanceof TileEntityDischargeMeter)
|
||||
state = state.withProperty(IEProperties.BOOLEANS[0], ((TileEntityDischargeMeter) te).hasWire);
|
||||
return state;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
|
||||
switch (state.getValue(PROPERTY)) {
|
||||
case DISCHARGE_METER:
|
||||
return new TileEntityDischargeMeter();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockTypes_GeneralHV[] getValues() {
|
||||
return BlockTypes_GeneralHV.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(PROPERTY).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(PROPERTY, getValues()[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,27 +1,24 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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;
|
||||
|
@ -93,7 +90,6 @@ 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,28 +1,25 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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;
|
||||
|
@ -146,24 +143,16 @@ public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacem
|
|||
return new ItemStack(this, 1, getMetaFromState(state));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
||||
super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);
|
||||
public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
||||
super.onEntityCollision(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,23 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.util;
|
||||
package malte0811.industrialwires.blocks.hv;
|
||||
|
||||
public interface TriConsumer<A, B, C> {
|
||||
void accept(A a, B b, C c);
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum BlockTypes_GeneralHV implements IStringSerializable{
|
||||
DISCHARGE_METER;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
}
|
|
@ -1,22 +1,19 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks.hv;
|
||||
package malte0811.industrialwires.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockIEBase;
|
||||
|
||||
|
@ -33,6 +30,7 @@ public enum BlockTypes_HVMultiblocks implements BlockIEBase.IBlockEnum {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* 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.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IPlayerInteraction;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.IBlockBoundsIW.IBlockBoundsDirectional;
|
||||
import malte0811.industrialwires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialwires.hv.IMarxTarget;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileEntityDischargeMeter extends TileEntityIWBase implements IPlayerInteraction, IMarxTarget,
|
||||
IBlockBoundsDirectional, IDirectionalTile {
|
||||
private static final String HAS_WIRE = "hasWire";
|
||||
private static final String FACING = "facing";
|
||||
private static final String LAST_DISCHARGE = "last";
|
||||
boolean hasWire;
|
||||
EnumFacing facing = EnumFacing.NORTH;
|
||||
double lastDischarge = -1;
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(FACING, (byte) facing.getHorizontalIndex());
|
||||
out.setBoolean(HAS_WIRE, hasWire);
|
||||
out.setDouble(LAST_DISCHARGE, lastDischarge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
hasWire = in.getBoolean(HAS_WIRE);
|
||||
facing = EnumFacing.byHorizontalIndex(in.getByte(FACING));
|
||||
lastDischarge = in.getDouble(LAST_DISCHARGE);
|
||||
aabb = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interact(@Nonnull EnumFacing side, @Nonnull EntityPlayer player, @Nonnull EnumHand hand,
|
||||
@Nonnull ItemStack heldItem, float hitX, float hitY, float hitZ) {
|
||||
if (!world.isRemote) {
|
||||
if (hasWire)
|
||||
return false;
|
||||
if (ApiUtils.compareToOreName(heldItem, "wireAluminum")) {
|
||||
hasWire = true;
|
||||
heldItem.shrink(1);
|
||||
triggerRenderUpdate();
|
||||
} else if (lastDischarge > 0) {
|
||||
player.sendMessage(new TextComponentTranslation(IndustrialWires.MODID + ".chat.marxEnergy",
|
||||
String.format("%.1f", lastDischarge/1e3)));
|
||||
lastDischarge = -1;
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHit(double energy, TileEntityMarx master) {
|
||||
if (hasWire) {
|
||||
hasWire = false;
|
||||
lastDischarge = energy;
|
||||
triggerRenderUpdate();
|
||||
markDirty();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
AxisAlignedBB aabb = null;
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBoxNoRot() {
|
||||
return new AxisAlignedBB(1F/16, 0, 5F/16,
|
||||
10F/16, (hasWire?15F:14F)/16, 11F/16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
if (aabb==null) {
|
||||
aabb = IBlockBoundsDirectional.super.getBoundingBox();
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@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,41 +1,39 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.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.network.MessageTileSyncIW;
|
||||
import malte0811.industrialWires.util.Beziers;
|
||||
import malte0811.industrialWires.util.DualEnergyStorage;
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -54,10 +52,8 @@ 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;
|
||||
|
@ -65,35 +61,34 @@ 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 {
|
||||
IEnergySink, IBlockBoundsIW, IDirectionalTile, IColoredLight, IEBlockInterfaces.IPlayerInteraction {
|
||||
public EnumFacing facing = EnumFacing.NORTH;
|
||||
private DualEnergyStorage energy;
|
||||
private JouleEnergyStorage energy;
|
||||
public LadderSize size;
|
||||
|
||||
public Vec3d[] controls;
|
||||
//first and last move along the "rails", only the middle points move in bezier curves
|
||||
public Vec3d[][] controlControls;
|
||||
private Vec3d[][] controlControls;
|
||||
// movement of the controls in blocks/tick
|
||||
public Vec3d[] controlMovement;
|
||||
private double t = 0;
|
||||
public int dummy = 0;
|
||||
private int dummy = 0;
|
||||
public int timeTillActive = -1;
|
||||
private double tStep = 0;
|
||||
private double consumtionEU;
|
||||
private boolean addedToIC2Net = false;
|
||||
private double consumtionJoule;
|
||||
private int soundPhase;
|
||||
private Vec3d soundPos;
|
||||
public double salt;
|
||||
|
||||
public TileEntityJacobsLadder(LadderSize s) {
|
||||
TileEntityJacobsLadder(LadderSize s) {
|
||||
size = s;
|
||||
initControl();
|
||||
}
|
||||
|
@ -108,8 +103,15 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
controlControls = new Vec3d[size.arcPoints - 2][size.movementPoints];
|
||||
controlMovement = new Vec3d[size.arcPoints];
|
||||
int sizeId = size.ordinal();
|
||||
consumtionEU = IWConfig.HVStuff.jacobsUsageEU[sizeId];
|
||||
energy = new DualEnergyStorage(20 * consumtionEU, 2 * consumtionEU);
|
||||
consumtionJoule = IWConfig.HVStuff.jacobsUsageWatt[sizeId];
|
||||
energy = new JouleEnergyStorage(20 * consumtionJoule,
|
||||
40 * consumtionJoule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
Compat.loadIC2Tile.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -119,10 +121,8 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
return;
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
if (hasIC2&&!addedToIC2Net) {
|
||||
addToIC2Net();
|
||||
}
|
||||
if ((controlControls[0][0] == null || timeTillActive == -1 || t >= 1) && energy.getEnergyStoredEU() >= 2 * consumtionEU) {
|
||||
if ((controlControls[0][0] == null || timeTillActive == -1 || t >= 1)
|
||||
&& energy.getEnergyStoredJ() >= 2 * consumtionJoule) {
|
||||
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.extractEU(consumtionEU, false);
|
||||
if (extracted >= consumtionEU) {
|
||||
energy.extractEU(consumtionEU, true);
|
||||
double extracted = energy.extract(consumtionJoule, 1, true);
|
||||
if (extracted >= consumtionJoule) {
|
||||
energy.extract(consumtionJoule, 1, false);
|
||||
} else {
|
||||
timeTillActive = -1 - size.delay;
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
@ -187,12 +187,6 @@ 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();
|
||||
|
@ -250,6 +244,7 @@ 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");
|
||||
|
@ -322,6 +317,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onSync(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("salt")) {
|
||||
salt = nbt.getDouble("salt");
|
||||
|
@ -334,7 +330,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
private boolean isActive() {
|
||||
if (isDummy()) {
|
||||
TileEntity master = world.getTileEntity(pos.down(dummy));
|
||||
return master instanceof TileEntityJacobsLadder && ((TileEntityJacobsLadder) master).isActive();
|
||||
|
@ -355,8 +351,9 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
e.attackEntityFrom(IWDamageSources.dmg_jacobs, IWConfig.HVStuff.jacobsBaseDmg * (size.ordinal() + 1));
|
||||
}
|
||||
|
||||
public boolean onActivated(EntityPlayer player, EnumHand hand) {
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
@Override
|
||||
public boolean interact(@Nonnull EnumFacing side, @Nonnull EntityPlayer player,@Nonnull EnumHand hand,
|
||||
@Nonnull ItemStack heldItem, float hitX, float hitY, float hitZ) {
|
||||
TileEntity masterTE = dummy == 0 ? this : world.getTileEntity(pos.down(dummy));
|
||||
if (masterTE instanceof TileEntityJacobsLadder) {
|
||||
TileEntityJacobsLadder master = (TileEntityJacobsLadder) masterTE;
|
||||
|
@ -420,7 +417,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
@Override
|
||||
@Optional.Method(modid = "ic2")
|
||||
public double getDemandedEnergy() {
|
||||
return energy.getEURequested();
|
||||
return energy.getRequested(ConversionUtil.euPerJoule());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -432,7 +429,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.insertEU(amount, true);
|
||||
return amount - energy.insert(amount, ConversionUtil.joulesPerEu(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -451,7 +448,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 (T) new EnergyCap();
|
||||
return CapabilityEnergy.ENERGY.cast(energy);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -460,31 +457,22 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (hasIC2) {
|
||||
removeFromIC2Net();
|
||||
Compat.unloadIC2Tile.accept(this);
|
||||
}
|
||||
addedToIC2Net = false;
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (hasIC2)
|
||||
removeFromIC2Net();
|
||||
Compat.unloadIC2Tile.accept(this);
|
||||
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
|
||||
|
@ -545,8 +533,8 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
return false;
|
||||
}
|
||||
|
||||
public static final float[] saltColor = {1, 190 / 255F, 50 / 255F};
|
||||
public static final float[] airColor = {1, .85F, 1};
|
||||
private static final float[] saltColor = {1, 190 / 255F, 50 / 255F};
|
||||
private static final float[] airColor = {1, .85F, 1};
|
||||
|
||||
private static final int factor = 20;
|
||||
private static final double smallMin = Math.exp(-.5);
|
||||
|
@ -646,37 +634,4 @@ 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,22 +1,19 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks.hv;
|
||||
package malte0811.industrialwires.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
|
@ -26,23 +23,25 @@ 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.IEContent;
|
||||
import blusunrize.immersiveengineering.common.IESaveData;
|
||||
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.MarxOreHandler;
|
||||
import malte0811.industrialWires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialWires.util.DualEnergyStorage;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -55,6 +54,7 @@ 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,9 +70,11 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
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 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 net.minecraft.item.EnumDyeColor.*;
|
||||
|
||||
/**
|
||||
|
@ -86,15 +88,11 @@ import static net.minecraft.item.EnumDyeColor.*;
|
|||
* Pink: Fine top cap voltage
|
||||
*/
|
||||
@Mod.EventBusSubscriber
|
||||
public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable, ISyncReceiver, IBlockBoundsIW, IImmersiveConnectable, IIC2Connector,
|
||||
public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable, ISyncReceiver, IBlockBoundsIW, IImmersiveConnectable, IMixedConnector,
|
||||
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;
|
||||
|
@ -105,8 +103,8 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
private int stageCount = 0;
|
||||
public FiringState state = FiringState.CHARGING;
|
||||
public Discharge dischargeData;
|
||||
// Voltage=100*storedEU
|
||||
private DualEnergyStorage storage = new DualEnergyStorage(50_000, 32_000);
|
||||
// Voltage=10*storedJ
|
||||
private JouleEnergyStorage storage = new JouleEnergyStorage(50_000, 20*32_000);
|
||||
private boolean hasConnection;
|
||||
private double[] capVoltages;
|
||||
private int voltageControl = 0;
|
||||
|
@ -128,7 +126,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_TAG);
|
||||
storage.writeToNbt(out, ENERGY);
|
||||
NBTTagList voltages = new NBTTagList();
|
||||
if (capVoltages != null) {
|
||||
for (int i = 0; i < stageCount; i++) {
|
||||
|
@ -149,7 +147,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_TAG));
|
||||
storage.readFromNBT(in.getCompoundTag(ENERGY));
|
||||
hasConnection = in.getBoolean(HAS_CONN);
|
||||
collisionAabb = null;
|
||||
renderAabb = null;
|
||||
|
@ -161,38 +159,83 @@ 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 IEContent.blockMetalDevice0.getDefaultState().withProperty(IEContent.blockMetalDevice0.property, BlockTypes_MetalDevice0.CAPACITOR_HV);
|
||||
return IEObjects.blockMetalDevice0.getDefaultState().withProperty(IEObjects.blockMetalDevice0.property, BlockTypes_MetalDevice0.CAPACITOR_HV);
|
||||
} else if (forward==-1) {
|
||||
return IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.RELAY_HV)
|
||||
return IEObjects.blockConnectors.getDefaultState().withProperty(IEObjects.blockConnectors.property, BlockTypes_Connector.RELAY_HV)
|
||||
.withProperty(IEProperties.FACING_ALL, facing);
|
||||
} else if (forward==4&&up==0&&right==1) {
|
||||
return IEContent.blockStorage.getDefaultState().withProperty(IEContent.blockStorage.property, BlockTypes_MetalsIE.STEEL);
|
||||
return IEObjects.blockStorage.getDefaultState().withProperty(IEObjects.blockStorage.property, BlockTypes_MetalsIE.STEEL);
|
||||
} else if (forward>0) {
|
||||
if ((right==0&&up==0)||(right==1&&up==stageCount-1)) {
|
||||
return IEContent.blockMetalDecoration1.getDefaultState().withProperty(IEContent.blockMetalDecoration1.property, BlockTypes_MetalDecoration1.STEEL_FENCE);
|
||||
return IEObjects.blockMetalDecoration1.getDefaultState().withProperty(IEObjects.blockMetalDecoration1.property, BlockTypes_MetalDecoration1.STEEL_FENCE);
|
||||
} else {
|
||||
return IEContent.blockMetalDecoration2.getDefaultState().withProperty(IEContent.blockMetalDecoration2.property, BlockTypes_MetalDecoration2.STEEL_WALLMOUNT)
|
||||
return IEObjects.blockMetalDecoration2.getDefaultState().withProperty(IEObjects.blockMetalDecoration2.property, BlockTypes_MetalDecoration2.STEEL_WALLMOUNT)
|
||||
.withProperty(IEProperties.INT_4, 1-right).withProperty(IEProperties.FACING_ALL, facing.getOpposite());
|
||||
}
|
||||
} else if (forward==-2) {
|
||||
return IEContent.blockMetalDecoration0.getDefaultState().withProperty(IEContent.blockMetalDecoration0.property, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING);
|
||||
return IEObjects.blockMetalDecoration0.getDefaultState().withProperty(IEObjects.blockMetalDecoration0.property, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING);
|
||||
} else if (right==0) {
|
||||
return IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.CONNECTOR_REDSTONE)
|
||||
return IEObjects.blockConnectors.getDefaultState().withProperty(IEObjects.blockConnectors.property, BlockTypes_Connector.CONNECTOR_REDSTONE)
|
||||
.withProperty(IEProperties.FACING_ALL, facing);
|
||||
} else {
|
||||
return IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.CONNECTOR_HV)
|
||||
return IEObjects.blockConnectors.getDefaultState().withProperty(IEObjects.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);
|
||||
|
@ -225,7 +268,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
//charge bottom cap from storage
|
||||
double setVoltage = MAX_VOLTAGE * voltageControl / 255F;
|
||||
double u0 = Math.min(setVoltage, 100 * storage.getEnergyStoredEU());
|
||||
double u0 = Math.min(setVoltage, 10 * storage.getEnergyStoredJ());
|
||||
if (u0 < 0) {
|
||||
u0 = 0;
|
||||
}
|
||||
|
@ -234,8 +277,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.extractEU(energyUsed, false) == energyUsed) {// energyUsed can be negative when discharging the caps
|
||||
storage.extractEU(energyUsed, true);
|
||||
if (energyUsed > 0 && storage.extract(energyUsed, 1, true) == energyUsed) {// energyUsed can be negative when discharging the caps
|
||||
storage.extract(energyUsed, 1, false);
|
||||
capVoltages[0] = tmp;
|
||||
} else if (energyUsed <= 0) {
|
||||
capVoltages[0] = tmp;
|
||||
|
@ -250,7 +293,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
state = FiringState.NEXT_TICK;
|
||||
}
|
||||
}
|
||||
leftover = storage.getMaxInputIF();
|
||||
leftover = storage.getMaxInPerTick();
|
||||
}
|
||||
|
||||
private void fire() {
|
||||
|
@ -286,12 +329,11 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
|
||||
private void handleOreProcessing(double energyStored) {
|
||||
BlockPos bottom = getBottomElectrode();
|
||||
Vec3d origin = new Vec3d(bottom).addVector(.5, 1, .5);
|
||||
Set<BlockPos> toBreak = new HashSet<>(stageCount-2);
|
||||
List<BlockPos> toBreak = new ArrayList<>(stageCount - 2);
|
||||
int ores = 0;
|
||||
for (int i = 1;i<stageCount-1;i++) {
|
||||
BlockPos blockHere = bottom.up(i);
|
||||
if (!world.isAirBlock(blockHere) && canBreak(blockHere)) {
|
||||
if (!world.isAirBlock(blockHere)) {
|
||||
toBreak.add(blockHere);
|
||||
ores++;
|
||||
}
|
||||
|
@ -304,6 +346,12 @@ 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);
|
||||
|
@ -324,7 +372,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;
|
||||
|
@ -349,7 +397,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()==IEContent.itemEarmuffs;
|
||||
boolean earMuff = helmet.getItem()==IEObjects.itemEarmuffs;
|
||||
if (!earMuff&&helmet.hasTagCompound()) {
|
||||
earMuff = helmet.getTagCompound().hasKey("IE:Earmuffs");
|
||||
}
|
||||
|
@ -366,16 +414,6 @@ 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);
|
||||
}
|
||||
|
@ -520,7 +558,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.insertIF(amount, master.leftover, !simulate);
|
||||
double ret = master.storage.insert(amount, ConversionUtil.joulesPerIf(), simulate, master.leftover);
|
||||
master.leftover -= ret;
|
||||
return (int) ret;
|
||||
} else {
|
||||
|
@ -529,12 +567,14 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public double insertEnergy(double eu, boolean simulate) {
|
||||
public double insertEnergy(double joules, boolean simulate) {
|
||||
TileEntityMarx master = master(this);
|
||||
if (master!=null) {
|
||||
double ret = master.storage.insertEU(eu, master.leftover, !simulate);
|
||||
master.leftover -= ret;
|
||||
return eu-ret;
|
||||
double ret = master.storage.insert(joules, 1, simulate, master.leftover);
|
||||
if (!simulate) {
|
||||
master.leftover -= ret;
|
||||
}
|
||||
return joules -ret;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -545,31 +585,34 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target) {
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) {
|
||||
if (hasConnection) {
|
||||
return false;
|
||||
}
|
||||
if (getRight()==0) {
|
||||
return cableType==WireType.REDSTONE;
|
||||
return REDSTONE_CATEGORY.equals(cableType.getCategory());
|
||||
} else {
|
||||
return cableType==WireType.STEEL||cableType== IC2Wiretype.IC2_TYPES[3];
|
||||
return WireType.HV_CATEGORY.equals(cableType.getCategory())|| IC2_HV_CAT.equals(cableType.getCategory());
|
||||
}
|
||||
}
|
||||
|
||||
@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:IC2Wiretype.IC2_TYPES[3];
|
||||
return getRight()==0?WireType.REDSTONE:MixedWireType.HV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowEnergyToPass(ImmersiveNetHandler.Connection con) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -588,7 +631,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection con) {
|
||||
Matrix4 transf = getBaseTransform();
|
||||
if (getRight()==0) {
|
||||
return transf.apply(new Vec3d(.5, .5, 7/16D));
|
||||
|
@ -597,24 +640,19 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection con) {
|
||||
return getRaytraceOffset(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validate()
|
||||
{
|
||||
super.validate();
|
||||
ImmersiveNetHandler.INSTANCE.resetCachedIndirectConnections();
|
||||
if (!world.isRemote)
|
||||
ApiUtils.addFutureServerTask(world, () -> ImmersiveNetHandler.INSTANCE.onTEValidated(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
if (world.isRemote)
|
||||
if (world.isRemote && !IndustrialWires.proxy.isSingleplayer())
|
||||
ImmersiveNetHandler.INSTANCE.clearConnectionsOriginatingFrom(pos, world);
|
||||
}
|
||||
|
||||
|
@ -708,16 +746,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.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());
|
||||
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());
|
||||
}
|
||||
origin = new Vec3d(offset(te.pos, te.facing, te.mirrored, 1, 0, 0))
|
||||
.addVector(0, .75, 0)
|
||||
.add(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.addVector(0, i, 0)).build());
|
||||
toAdd.add(builder.pos(origin.add(0, i, 0)).build());
|
||||
}
|
||||
event.getLightList().addAll(toAdd);
|
||||
}
|
||||
|
@ -762,12 +800,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.lengthVector();
|
||||
double diffLength = diff.length();
|
||||
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.lengthVector()));
|
||||
v0 = v0.scale((float) (noise / v0.length()));
|
||||
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-2017 malte0811
|
||||
*
|
||||
* 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.blocks.wire;
|
||||
package malte0811.industrialwires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
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 net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
@ -40,6 +40,8 @@ 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;
|
||||
|
@ -47,7 +49,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
||||
private static final PropertyEnum<BlockTypes_IC2_Connector> type = PropertyEnum.create("type", BlockTypes_IC2_Connector.class);
|
||||
public static final PropertyEnum<BlockTypes_IC2_Connector> TYPE = PropertyEnum.create("type", BlockTypes_IC2_Connector.class);
|
||||
public static final String NAME = "ic2_connector";
|
||||
|
||||
public BlockIC2Connector() {
|
||||
|
@ -58,11 +60,11 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos posNeighbor) {
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof TileEntityIC2ConnectorTin) {
|
||||
TileEntityIC2ConnectorTin connector = (TileEntityIC2ConnectorTin) te;
|
||||
if (world.isAirBlock(pos.offset(connector.facing))) {
|
||||
if (world.isAirBlock(pos.offset(connector.getFacing()))) {
|
||||
this.dropBlockAsItem(connector.getWorld(), pos, world.getBlockState(pos), 0);
|
||||
connector.getWorld().setBlockToAir(pos);
|
||||
}
|
||||
|
@ -71,7 +73,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));
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +90,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
|
||||
|
@ -105,7 +107,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
|
||||
|
@ -120,7 +122,15 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
|
||||
switch (state.getValue(type)) {
|
||||
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) {
|
||||
case TIN_CONN:
|
||||
return new TileEntityIC2ConnectorTin(false);
|
||||
case TIN_RELAY:
|
||||
|
@ -146,12 +156,16 @@ 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 + 1));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.eu_per_tick", IC2Wiretype.IC2_TYPES[type].getTransferRate() / 8));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,6 +205,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,21 +1,18 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks.wire;
|
||||
package malte0811.industrialwires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockIEBase.IBlockEnum;
|
||||
|
|
@ -1,42 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks.wire;
|
||||
package malte0811.industrialwires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import static malte0811.industrialwires.wires.MixedWireType.COPPER_IC2;
|
||||
|
||||
public class TileEntityIC2ConnectorCopper extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorCopper(boolean rel) {
|
||||
super(rel);
|
||||
super(rel, COPPER_IC2, 2, .5, .5);
|
||||
}
|
||||
|
||||
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,40 +1,27 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.blocks.wire;
|
||||
package malte0811.industrialwires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import static malte0811.industrialwires.wires.MixedWireType.GLASS;
|
||||
|
||||
public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorHV {
|
||||
public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorTin {
|
||||
public TileEntityIC2ConnectorGlass(boolean rel) {
|
||||
super(rel);
|
||||
super(rel, GLASS, 5, .875, .75);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorGlass() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 5;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[4].getTransferRate() / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[4];
|
||||
this(false);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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.blocks.wire;
|
||||
|
||||
import static malte0811.industrialwires.wires.MixedWireType.GOLD;
|
||||
|
||||
public class TileEntityIC2ConnectorGold extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorGold(boolean rel) {
|
||||
super(rel, GOLD, 3, .5625, .5625);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorGold() {
|
||||
this(false);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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.blocks.wire;
|
||||
|
||||
import static malte0811.industrialwires.wires.MixedWireType.HV;
|
||||
|
||||
public class TileEntityIC2ConnectorHV extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorHV(boolean rel) {
|
||||
super(rel, HV, 4, .875, .75);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorHV() {
|
||||
this(false);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,648 @@
|
|||
/*
|
||||
* 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.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.api.TargetingInfo;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.*;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.AbstractConnection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import com.cout970.magneticraft.api.core.INode;
|
||||
import com.cout970.magneticraft.api.energy.IElectricNode;
|
||||
import com.cout970.magneticraft.api.energy.IElectricNodeHandler;
|
||||
import com.cout970.magneticraft.registry.CapabilitiesKt;
|
||||
import com.cout970.magneticraft.systems.config.Config;
|
||||
import gregtech.api.capability.GregtechCapabilities;
|
||||
import gregtech.api.capability.IEnergyContainer;
|
||||
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.IMixedConnector;
|
||||
import malte0811.industrialwires.IWConfig;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialwires.compat.Compat;
|
||||
import malte0811.industrialwires.util.ConversionUtil;
|
||||
import malte0811.industrialwires.util.MiscUtils;
|
||||
import malte0811.industrialwires.wires.MixedWireType;
|
||||
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.*;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
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.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialwires.wires.MixedWireType.TIN;
|
||||
|
||||
@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, IMixedConnector, IBlockBoundsIW {
|
||||
private static final double EPS = .1;
|
||||
private EnumFacing facing = EnumFacing.NORTH;
|
||||
private boolean relay;
|
||||
// external net to IE net buffer
|
||||
private double bufferToNet = 0;
|
||||
private double potentialIEInputInTick = 0;
|
||||
private double actualIEInputInTick = 0;
|
||||
private double maxToNet = 0;
|
||||
//IE net to external net buffer
|
||||
private double bufferToMachine = 0;
|
||||
private double externalInputInTick = 0;
|
||||
private double maxToMachine = 0;
|
||||
//private EnergyType energyType = NONE;
|
||||
private boolean shouldBreak = false;
|
||||
private final double maxIO;
|
||||
private final MixedWireType wireType;
|
||||
private final int tier;
|
||||
private final double relayOffset;
|
||||
private final double connOffset;
|
||||
|
||||
protected TileEntityIC2ConnectorTin(boolean relay, MixedWireType type, int tier, double relayLength, double connLength) {
|
||||
this.relay = relay;
|
||||
wireType = type;
|
||||
maxIO = type.getIORate();
|
||||
this.tier = tier;
|
||||
this.relayOffset = relayLength-.5;
|
||||
this.connOffset = connLength-.5;
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorTin(boolean relay) {
|
||||
this(relay, TIN, 1, .5, .5);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorTin() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
if (!world.isRemote&& IndustrialWires.hasIC2)
|
||||
Compat.loadIC2Tile.accept(this);
|
||||
ImmersiveNetHandler.INSTANCE.onTEValidated(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!world.isRemote) {
|
||||
if (shouldBreak) {
|
||||
Deque<BlockPos> open = new ArrayDeque<>();
|
||||
open.push(pos);
|
||||
Set<BlockPos> closed = new HashSet<>();
|
||||
closed.add(pos);
|
||||
while (!open.isEmpty()) {
|
||||
BlockPos next = open.pop();
|
||||
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(world, next);
|
||||
if (conns!=null) {
|
||||
for (Connection c:conns) {
|
||||
ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension())
|
||||
.put(c, 2*c.cableType.getTransferRate());
|
||||
if (closed.add(c.end)) {
|
||||
open.push(c.end);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (BlockPos p:closed) {
|
||||
TileEntity tile = world.getTileEntity(p);
|
||||
if (tile instanceof IImmersiveConnectable && ((IImmersiveConnectable) tile).isEnergyOutput()) {
|
||||
world.createExplosion(null, p.getX()+.5, p.getY()+.5, p.getZ()+.5,
|
||||
3, true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (bufferToNet < maxToNet) {
|
||||
maxToNet = bufferToNet;
|
||||
}
|
||||
if (externalInputInTick > maxToNet) {
|
||||
maxToNet = externalInputInTick;
|
||||
}
|
||||
externalInputInTick = 0;
|
||||
|
||||
if (bufferToMachine < maxToMachine) {
|
||||
maxToMachine = bufferToMachine;
|
||||
}
|
||||
potentialIEInputInTick = Math.min(Math.max(potentialIEInputInTick, actualIEInputInTick), getMaxIO());
|
||||
if (potentialIEInputInTick > maxToMachine) {
|
||||
maxToMachine = potentialIEInputInTick;
|
||||
}
|
||||
potentialIEInputInTick = 0;
|
||||
actualIEInputInTick = 0;
|
||||
if (bufferToNet > EPS) {
|
||||
transferPowerToNet();
|
||||
}
|
||||
if (bufferToNet >EPS) {
|
||||
notifyAvailableEnergy(bufferToNet);
|
||||
}
|
||||
if (bufferToMachine > EPS) {
|
||||
transferPowerToFEMachine();
|
||||
if (Loader.isModLoaded("gregtech"))
|
||||
transferPowerToGTMachine();
|
||||
if (Loader.isModLoaded("magneticraft"))
|
||||
transferPowerToMagn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void transferPowerToNet() {
|
||||
Set<AbstractConnection> conns = ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world, true);
|
||||
Map<AbstractConnection, Pair<IMixedConnector, Double>> maxOutputs = new HashMap<>();
|
||||
double outputMax = Math.min(bufferToNet, maxToNet);
|
||||
double sum = 0;
|
||||
for (AbstractConnection c : conns) {
|
||||
if (c.isEnergyOutput) {
|
||||
IImmersiveConnectable iic = ApiUtils.toIIC(c.end, world);
|
||||
if (iic instanceof IMixedConnector) {
|
||||
double extract =
|
||||
outputMax - ((IMixedConnector) iic).insertEnergy(outputMax, true);
|
||||
if (extract > EPS) {
|
||||
maxOutputs.put(c, new ImmutablePair<>((IMixedConnector) iic, extract));
|
||||
sum += extract;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sum > EPS) {
|
||||
HashMap<Connection, Integer> transferedPerConn = ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension());
|
||||
for (Map.Entry<AbstractConnection, Pair<IMixedConnector, Double>> entry : maxOutputs.entrySet()) {
|
||||
Pair<IMixedConnector, Double> p = entry.getValue();
|
||||
AbstractConnection c = entry.getKey();
|
||||
double out = outputMax * p.getRight() / sum;
|
||||
double loss = Math.min(getAverageLossRate(c), 1)*out;
|
||||
out = Math.min(out, bufferToNet -loss);
|
||||
if (out<=0)
|
||||
continue;
|
||||
double inserted = out - p.getLeft().insertEnergy(out, false);
|
||||
double energyAtConn = inserted + loss;
|
||||
bufferToNet -= energyAtConn;
|
||||
float intermediaryLoss = 0;
|
||||
HashSet<IImmersiveConnectable> passedConnectors = new HashSet<>();
|
||||
for (Connection sub : c.subConnections) {
|
||||
int transferredPerCon = transferedPerConn.getOrDefault(sub, 0);
|
||||
energyAtConn -= sub.cableType.getLossRatio() * sub.length;
|
||||
double wireLoad = energyAtConn;
|
||||
transferedPerConn.put(sub, (int) (transferredPerCon + wireLoad));
|
||||
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 void transferPowerToFEMachine() {
|
||||
BlockPos outPos = pos.offset(facing);
|
||||
TileEntity te = MiscUtils.getLoadedTE(world, outPos, TileEntity.class);
|
||||
if (te!=null && te.hasCapability(CapabilityEnergy.ENERGY, facing.getOpposite())) {
|
||||
IEnergyStorage handler = te.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite());
|
||||
assert handler!=null;
|
||||
double outJoules = Math.min(bufferToMachine, maxToMachine*IWConfig.wireRatio);
|
||||
int outFE = MathHelper.floor(outJoules*ConversionUtil.ifPerJoule());
|
||||
int received = handler.receiveEnergy(outFE, false);
|
||||
bufferToMachine -= received*ConversionUtil.joulesPerIf();
|
||||
}
|
||||
}
|
||||
|
||||
private void transferPowerToGTMachine() {
|
||||
BlockPos outPos = pos.offset(facing);
|
||||
TileEntity te = MiscUtils.getLoadedTE(world, outPos, TileEntity.class);
|
||||
if (te!=null && te.hasCapability(GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, facing.getOpposite())) {
|
||||
IEnergyContainer container = te.getCapability(GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, facing.getOpposite());
|
||||
assert container!=null;
|
||||
double outJoules = Math.min(bufferToMachine, maxToMachine*IWConfig.wireRatio);
|
||||
long outEU = Math.min(MathHelper.floor(outJoules*ConversionUtil.euPerJoule()), container.getInputVoltage());
|
||||
long received = container.addEnergy(outEU);
|
||||
bufferToMachine -= received*ConversionUtil.joulesPerEu();
|
||||
}
|
||||
}
|
||||
|
||||
private void transferPowerToMagn() {
|
||||
BlockPos outPos = pos.offset(facing);
|
||||
TileEntity te = MiscUtils.getLoadedTE(world, outPos, TileEntity.class);
|
||||
if (te!=null && te.hasCapability(CapabilitiesKt.getELECTRIC_NODE_HANDLER(), facing.getOpposite())) {
|
||||
IElectricNodeHandler handler = te.getCapability(CapabilitiesKt.getELECTRIC_NODE_HANDLER(), facing.getOpposite());
|
||||
assert handler!=null;
|
||||
double outJoules = Math.min(bufferToMachine, maxToMachine*IWConfig.wireRatio);
|
||||
int outRF = MathHelper.floor(outJoules*ConversionUtil.ifPerJoule());
|
||||
IElectricNode node = null;
|
||||
for (INode n : handler.getNodes()) {
|
||||
if (n instanceof IElectricNode) {
|
||||
node = (IElectricNode) n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (node != null) {
|
||||
double insertet = node.applyPower(outRF * Config.INSTANCE.getWattsToFE(), false);
|
||||
bufferToMachine -= insertet/Config.INSTANCE.getWattsToFE();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyAvailableEnergy(double storedNew)
|
||||
{
|
||||
Set<AbstractConnection> outputs = ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world, true);
|
||||
for(AbstractConnection con : outputs)
|
||||
{
|
||||
IImmersiveConnectable end = ApiUtils.toIIC(con.end, world);
|
||||
if(con.cableType!=null && end!=null && end.allowEnergyToPass(null))
|
||||
{
|
||||
Pair<Float, Consumer<Float>> e = getEnergyForConnection(con, storedNew);
|
||||
end.addAvailableEnergy(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
addAvailableEnergy(-1, null);
|
||||
}
|
||||
|
||||
private Pair<Float, Consumer<Float>> getEnergyForConnection(@Nullable AbstractConnection c, double storedNew)
|
||||
{
|
||||
float loss = c!=null?c.getAverageLossRate():0;
|
||||
float max = (float) (storedNew-loss);
|
||||
Consumer<Float> extract = (energy)-> bufferToNet -= energy+loss;
|
||||
return new ImmutablePair<>(max, extract);
|
||||
}
|
||||
|
||||
private double getAverageLossRate(AbstractConnection conn) {
|
||||
double f = 0;
|
||||
for (Connection c : conn.subConnections) {
|
||||
WireType type = c.cableType;
|
||||
if (type instanceof MixedWireType) {
|
||||
f += c.length * ((MixedWireType)type).getLoss();
|
||||
} else {
|
||||
f = Double.POSITIVE_INFINITY;
|
||||
}
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
//Input through the net
|
||||
@Override
|
||||
public double insertEnergy(double joules, boolean simulate) {
|
||||
double insert = Math.min(getMaxIO() - bufferToMachine, joules);
|
||||
insert = Math.min(getMaxIO()-actualIEInputInTick, insert);
|
||||
if (!simulate) {
|
||||
bufferToMachine += insert;
|
||||
actualIEInputInTick += insert;
|
||||
} else {
|
||||
//Yes, this is weird. But it works, otherwise the system can get stuck at a lower output rate with a full buffer
|
||||
potentialIEInputInTick += Math.min(joules, getMaxIO());
|
||||
}
|
||||
return joules - insert;
|
||||
}
|
||||
|
||||
private double getMaxIO() {
|
||||
return maxIO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (!world.isRemote)
|
||||
Compat.unloadIC2Tile.accept(this);
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
if (!world.isRemote)
|
||||
Compat.unloadIC2Tile.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
double conRadius = con.cableType.getRenderDiameter() / 2;
|
||||
double length = relay?relayOffset:connOffset;
|
||||
return new Vec3d(.5 + (length - conRadius) * side.getXOffset(),
|
||||
.5 + (length - conRadius) * side.getYOffset(),
|
||||
.5 + (length - conRadius) * side.getZOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnergyOutput() {
|
||||
return !relay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) {
|
||||
return (limitType == null || this.isRelay()) && WireApi.canMix(cableType, wireType);
|
||||
}
|
||||
|
||||
@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 = (getMaxIO() - bufferToNet) * ConversionUtil.euPerJoule() + .05;
|
||||
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) {
|
||||
return amount-ConversionUtil.euPerJoule()*addToIn(ConversionUtil.joulesPerEu()*amount, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public double getOfferedEnergy() {
|
||||
return Math.min(maxToMachine, bufferToMachine) * ConversionUtil.euPerJoule();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public void drawEnergy(double amount) {
|
||||
bufferToMachine -= amount*ConversionUtil.joulesPerEu();
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Pair<Float,Consumer<Float>> getOwnEnergy()
|
||||
{
|
||||
if (isRelay())
|
||||
return null;
|
||||
return new ImmutablePair<>((float) bufferToNet, (d)-> bufferToNet -= d);
|
||||
}
|
||||
@Override
|
||||
protected float getBaseDamage(ImmersiveNetHandler.Connection c) {
|
||||
return 1/64F;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public int getSourceTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
// Returns amount of energy consumed
|
||||
private double addToIn(double joules, boolean simulate) {
|
||||
joules = Math.min(getMaxIO() - externalInputInTick + .5, joules);
|
||||
if (bufferToNet < getMaxIO()) {
|
||||
if (!simulate) {
|
||||
bufferToNet += joules;
|
||||
externalInputInTick += joules;
|
||||
notifyAvailableEnergy(joules);
|
||||
}
|
||||
markDirty();
|
||||
return joules;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(@Nonnull NBTTagCompound nbt, boolean descPacket) {
|
||||
super.readCustomNBT(nbt, descPacket);
|
||||
facing = EnumFacing.byIndex(nbt.getInteger("facing"));
|
||||
relay = nbt.getBoolean("relay");
|
||||
int version = nbt.getInteger("version");
|
||||
bufferToNet = nbt.getDouble("inBuffer");
|
||||
bufferToMachine = nbt.getDouble("outBuffer");
|
||||
if (nbt.hasKey("maxToNet")) {
|
||||
maxToNet = nbt.getDouble("maxToNet");
|
||||
} else {
|
||||
maxToNet = bufferToNet;
|
||||
}
|
||||
if (nbt.hasKey("maxToMachine")) {
|
||||
maxToMachine = nbt.getDouble("maxToMachine");
|
||||
} else {
|
||||
maxToMachine = bufferToMachine;
|
||||
}
|
||||
if (version==0) {
|
||||
bufferToNet *= ConversionUtil.joulesPerEu();
|
||||
bufferToMachine *= ConversionUtil.joulesPerEu();
|
||||
maxToNet *= ConversionUtil.joulesPerEu();
|
||||
maxToMachine *= ConversionUtil.joulesPerEu();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(@Nonnull NBTTagCompound nbt, boolean descPacket) {
|
||||
super.writeCustomNBT(nbt, descPacket);
|
||||
nbt.setInteger("facing", facing.getIndex());
|
||||
nbt.setBoolean("relay", relay);
|
||||
nbt.setDouble("inBuffer", bufferToNet);
|
||||
nbt.setDouble("outBuffer", bufferToMachine);
|
||||
nbt.setDouble("maxToNet", maxToNet);
|
||||
nbt.setDouble("maxToMachine", maxToMachine);
|
||||
nbt.setInteger("version", 1);
|
||||
}
|
||||
|
||||
@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() {
|
||||
double length = .5+(relay?relayOffset:connOffset);
|
||||
double wMin = .3125;
|
||||
double wMax = .6875;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
if (capability==CapabilityEnergy.ENERGY) {
|
||||
return !isRelay() && facing == this.facing;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability==CapabilityEnergy.ENERGY) {
|
||||
if (!isRelay() && facing == this.facing) {
|
||||
return CapabilityEnergy.ENERGY.cast(energyHandler);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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() {
|
||||
if (world==null)
|
||||
return 0;
|
||||
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;
|
||||
}
|
||||
|
||||
private EnergyHandler energyHandler = new EnergyHandler();
|
||||
|
||||
private class EnergyHandler implements IEnergyStorage {
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
if (bufferToNet>=getMaxIO()) {
|
||||
return 0;
|
||||
}
|
||||
double joules = maxReceive*ConversionUtil.joulesPerIf();
|
||||
double accepted = addToIn(joules, simulate);
|
||||
return MathHelper.ceil(accepted*ConversionUtil.ifPerJoule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
double joules = maxExtract*ConversionUtil.joulesPerIf();
|
||||
if (joules>maxToMachine) {
|
||||
joules = maxToMachine;
|
||||
}
|
||||
if (joules>bufferToMachine) {
|
||||
joules = bufferToMachine;
|
||||
}
|
||||
if (!simulate) {
|
||||
bufferToMachine -= joules;
|
||||
}
|
||||
return MathHelper.floor(ConversionUtil.ifPerJoule()*joules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
return (int)((bufferToMachine+bufferToNet)*ConversionUtil.ifPerJoule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
return (int) (2* getMaxIO() *ConversionUtil.ifPerJoule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtract() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +1,44 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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;
|
||||
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 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 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 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;
|
||||
|
@ -45,16 +46,20 @@ 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.DrawBlockHighlightEvent;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.*;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
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;
|
||||
|
||||
|
@ -62,9 +67,13 @@ 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 {
|
||||
@SubscribeEvent
|
||||
public static boolean shouldScreenshot = false;
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public static void renderOverlayPost(RenderGameOverlayEvent.Post e) {
|
||||
if (ClientUtils.mc().player != null && e.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
|
||||
EntityPlayer player = ClientUtils.mc().player;
|
||||
|
@ -73,10 +82,17 @@ 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)) {
|
||||
IC2Wiretype type = IC2Wiretype.IC2_TYPES[equipped.getItemDamage()];
|
||||
MixedWireType type = MixedWireType.ALL[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) {
|
||||
|
@ -92,7 +108,8 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +126,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(panel);
|
||||
pc.getLeft().renderBox();
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
@ -171,4 +188,32 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
512
src/main/java/malte0811/industrialwires/client/ClientProxy.java
Normal file
512
src/main/java/malte0811/industrialwires/client/ClientProxy.java
Normal file
|
@ -0,0 +1,512 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ManualHelper;
|
||||
import blusunrize.immersiveengineering.api.ManualPageMultiblock;
|
||||
import blusunrize.immersiveengineering.client.ClientUtils;
|
||||
import blusunrize.immersiveengineering.common.Config;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import blusunrize.lib.manual.IManualPage;
|
||||
import blusunrize.lib.manual.ManualInstance;
|
||||
import blusunrize.lib.manual.ManualPages;
|
||||
import blusunrize.lib.manual.ManualPages.PositionedItemStack;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import malte0811.industrialwires.*;
|
||||
import malte0811.industrialwires.blocks.controlpanel.BlockTypes_Panel;
|
||||
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.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.multiblock_io_model.MBIOModelLoader;
|
||||
import malte0811.industrialwires.client.panelmodel.PanelModelLoader;
|
||||
import malte0811.industrialwires.client.render.*;
|
||||
import malte0811.industrialwires.compat.Compat;
|
||||
import malte0811.industrialwires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialwires.crafting.IC2TRHelper;
|
||||
import malte0811.industrialwires.entities.EntityBrokenPart;
|
||||
import malte0811.industrialwires.hv.MarxOreHandler;
|
||||
import malte0811.industrialwires.hv.MultiblockMarx;
|
||||
import malte0811.industrialwires.items.ItemIC2Coil;
|
||||
import malte0811.industrialwires.items.ItemPanelComponent;
|
||||
import malte0811.industrialwires.mech_mb.*;
|
||||
import malte0811.industrialwires.util.CommandIWClient;
|
||||
import malte0811.industrialwires.util.ConversionUtil;
|
||||
import malte0811.industrialwires.util.MiscUtils;
|
||||
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.audio.SoundHandler;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
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.ClientCommandHandler;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static malte0811.industrialwires.IndustrialWires.*;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
public void preInit() {
|
||||
super.preInit();
|
||||
OBJLoader.INSTANCE.addDomain(IndustrialWires.MODID);
|
||||
ModelLoaderRegistry.registerLoader(new PanelModelLoader());
|
||||
ModelLoaderRegistry.registerLoader(new MBIOModelLoader());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJacobsLadder.class, new TileRenderJacobsLadder());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMarx.class, new TileRenderMarx());
|
||||
TileRenderMechMB tesr = new TileRenderMechMB();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMechMB.class, tesr);
|
||||
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(tesr);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityBrokenPart.class, EntityRenderBrokenPart::new);
|
||||
|
||||
Shaders.initShaders(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
super.postInit();
|
||||
ManualInstance m = ManualHelper.getManual();
|
||||
boolean uni = m.fontRenderer.getUnicodeFlag();
|
||||
m.fontRenderer.setUnicodeFlag(true);
|
||||
m.entryRenderPre();
|
||||
TextSplitter splitter;
|
||||
{
|
||||
PositionedItemStack[][] wireRecipes = new PositionedItemStack[3][10];
|
||||
int xBase = 15;
|
||||
Ingredient copperCable = IC2TRHelper.getStack("cable", "type:copper,insulation:0");
|
||||
Object2IntMap<ItemStack> copperCables = new Object2IntLinkedOpenHashMap<>();
|
||||
for (ItemStack itemStack : copperCable.getMatchingStacks()) {
|
||||
copperCables.put(itemStack, 1);
|
||||
}
|
||||
copperCables.put(new ItemStack(IEObjects.itemWireCoil, 1, 0), 8);
|
||||
List<ItemStack> copperCableList = new ArrayList<>(copperCables.keySet());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
wireRecipes[0][3 * i + j] = new PositionedItemStack(copperCableList, 18 * i + xBase, 18 * j);
|
||||
}
|
||||
}
|
||||
ItemStack copperCoil = new ItemStack(IndustrialWires.coil, 1, 1);
|
||||
ItemIC2Coil.setLength(copperCoil, 9);
|
||||
wireRecipes[0][9] = new PositionedItemStack(copperCoil, 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.nextDouble() > 1 / (1. + copperCables.size())) {
|
||||
// cable
|
||||
ItemStack chosen = copperCableList.get(r.nextInt(copperCables.size()));
|
||||
lengthSum += copperCables.getInt(chosen);
|
||||
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(chosen, 18 * j1 + xBase, 18 * j2);
|
||||
} else {
|
||||
// wire coil
|
||||
int length = r.nextInt(99) + 1;
|
||||
copperCoil = new ItemStack(IndustrialWires.coil, 1, 1);
|
||||
ItemIC2Coil.setLength(copperCoil, length);
|
||||
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(copperCoil, 18 * j1 + xBase, 18 * j2);
|
||||
lengthSum += length;
|
||||
}
|
||||
}
|
||||
}
|
||||
copperCoil = new ItemStack(IndustrialWires.coil);
|
||||
ItemIC2Coil.setLength(copperCoil, lengthSum);
|
||||
wireRecipes[i][9] = new PositionedItemStack(copperCoil, 18 * 4 + xBase, 18);
|
||||
}
|
||||
|
||||
splitter = new TextSplitter(m);
|
||||
splitter.addSpecialPage(0, 0, 10,
|
||||
s->new ManualPages.CraftingMulti(m, s, (Object[]) wireRecipes));
|
||||
String text = I18n.format("ie.manual.entry.industrialwires.wires");
|
||||
splitter.split(text);
|
||||
List<IManualPage> entry = splitter.toManualEntry();
|
||||
m.addEntry("industrialwires.wires", IndustrialWires.MODID, entry.toArray(new IManualPage[0]));
|
||||
}
|
||||
if (hasIC2 && 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))
|
||||
);
|
||||
}
|
||||
addUnblockableSounds(TINNITUS, TURN_FAST, TURN_SLOW);
|
||||
|
||||
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.jacobsUsageWatt);
|
||||
Config.manual_double.put("iwFluxPerJoule", ConversionUtil.ifPerJoule());
|
||||
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"));
|
||||
|
||||
|
||||
String text = I18n.format("ie.manual.entry.industrialwires.intro");
|
||||
splitter = new TextSplitter(m);
|
||||
splitter.addSpecialPage(0, 0, 9, s -> new ManualPages.Crafting(m, s,
|
||||
new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.DUMMY.ordinal())));
|
||||
splitter.addSpecialPage(1, 0, 9, s -> new ManualPages.Crafting(m, s,
|
||||
new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.UNFINISHED.ordinal())));
|
||||
splitter.split(text);
|
||||
m.addEntry("industrialwires.intro", "control_panels",
|
||||
splitter.toManualEntry().toArray(new IManualPage[0])
|
||||
);
|
||||
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")
|
||||
);
|
||||
text = I18n.format("ie.manual.entry.industrialwires.redstone");
|
||||
splitter = new TextSplitter(m);
|
||||
splitter.addSpecialPage(-1, 0, Compat.enableOtherRS ? 9 : 12, s -> new ManualPages.CraftingMulti(m, s,
|
||||
new ResourceLocation(IndustrialWires.MODID, "control_panel_rs_other"),
|
||||
new ResourceLocation(IndustrialWires.MODID, "control_panel_rs_wire")));
|
||||
splitter.split(text);
|
||||
m.addEntry("industrialwires.redstone", "control_panels",
|
||||
splitter.toManualEntry().toArray(new IManualPage[0])
|
||||
);
|
||||
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)),
|
||||
new ManualPages.Crafting(m, "industrialwires.rgb_led", new ItemStack(IndustrialWires.panelComponent, 1, 10))
|
||||
);
|
||||
List<MarxOreHandler.OreInfo> ores = MarxOreHandler.getRecipes();
|
||||
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>";
|
||||
}
|
||||
}
|
||||
splitter = new TextSplitter(m);
|
||||
splitter.addSpecialPage(0, 0, 6,
|
||||
(s) -> new ManualPageMultiblock(m, s,
|
||||
MultiblockMarx.INSTANCE));
|
||||
splitter.split(text);
|
||||
List<IManualPage> marxEntry = splitter.toManualEntry();
|
||||
m.addEntry("industrialwires.marx", IndustrialWires.MODID, marxEntry.toArray(new IManualPage[0]));
|
||||
|
||||
text = I18n.format("ie.manual.entry.industrialwires.mech_mb");
|
||||
splitter = new TextSplitter(m);
|
||||
splitter.addSpecialPage(0, 0, 8, (s) -> new ManualPageMultiblock(m, s,
|
||||
MiscUtils.getMBFromName(MechMBPart.EXAMPLE_MECHMB_LOC.toString())));
|
||||
splitter.split(text);
|
||||
List<IManualPage> mechMBEntry = splitter.toManualEntry();
|
||||
m.addEntry("industrialwires.mech_mb", IndustrialWires.MODID, mechMBEntry.toArray(new IManualPage[0]));
|
||||
|
||||
String[][] flywheelTable;
|
||||
{
|
||||
List<String[]> flywheelTableList = new ArrayList<>(1 + Material.values().length);
|
||||
flywheelTableList.add(new String[]{"industrialwires.desc.material", "industrialwires.desc.inertia", "industrialwires.desc.max_speed"});
|
||||
for (Material mat : Material.values()) {
|
||||
MechPartFlywheel f = new MechPartFlywheel(mat);
|
||||
flywheelTableList.add(new String[]{mat.oreName(), Utils.formatDouble(f.getInertia(), "0.#"),
|
||||
Utils.formatDouble(f.getMaxSpeed(), "0.#")});
|
||||
}
|
||||
flywheelTable = flywheelTableList.toArray(new String[0][]);
|
||||
}
|
||||
text = I18n.format("ie.manual.entry.industrialwires.mech_mb_parts");
|
||||
splitter = new TextSplitter(m);
|
||||
splitter.addSpecialPage(0, 0, 10, (s) -> new ManualPageMultiblock(m, s,
|
||||
MechMBPart.getManualMBForPart(MechPartFlywheel.class)));
|
||||
splitter.addSpecialPage(1, 0, 1, s -> new ManualPages.Table(m, "", flywheelTable, true));
|
||||
splitter.addSpecialPage(2, 0, 10, (s) -> new ManualPageMultiblock(m, s,
|
||||
MechMBPart.getManualMBForPart(MechPartSingleCoil.class)));
|
||||
splitter.addSpecialPage(3, 0, 10, (s) -> new ManualPageMultiblock(m, s,
|
||||
MechMBPart.getManualMBForPart(MechPartFourElectrodes.class)));
|
||||
if (IWConfig.MechConversion.allowMBEU()) {
|
||||
text += I18n.format("ie.manual.entry.industrialwires.mech_mb_parts.commutator");
|
||||
splitter.addSpecialPage(4, 0, 10, (s) -> new ManualPageMultiblock(m, s,
|
||||
MechMBPart.getManualMBForPart(MechPartCommutator4Phase.class)));
|
||||
}
|
||||
splitter.split(text);
|
||||
List<IManualPage> partsEntry = splitter.toManualEntry();
|
||||
m.addEntry("industrialwires.mech_mb_parts", IndustrialWires.MODID, partsEntry.toArray(new IManualPage[0]));
|
||||
m.entryRenderPost();
|
||||
m.fontRenderer.setUnicodeFlag(uni);
|
||||
|
||||
ClientCommandHandler.instance.registerCommand(new CommandIWClient());
|
||||
}
|
||||
|
||||
private static ISound playingTinnitus = null;
|
||||
|
||||
private void addUnblockableSounds(SoundEvent... sounds) {
|
||||
int oldLength = Config.IEConfig.Tools.earDefenders_SoundBlacklist.length;
|
||||
Config.IEConfig.Tools.earDefenders_SoundBlacklist =
|
||||
Arrays.copyOf(Config.IEConfig.Tools.earDefenders_SoundBlacklist, oldLength + sounds.length);
|
||||
for (int i = 0;i<sounds.length;i++) {
|
||||
Config.IEConfig.Tools.earDefenders_SoundBlacklist[oldLength+i] = sounds[i].getSoundName().toString();
|
||||
}
|
||||
}
|
||||
@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(TINNITUS, 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 Map<BlockPos, List<ISound>> playingSounds = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void playJacobsLadderSound(TileEntityJacobsLadder te, int phase, Vec3d soundPos) {
|
||||
stopAllSoundsExcept(te.getPos(), ImmutableSet.of());
|
||||
SoundEvent event;
|
||||
switch (phase) {
|
||||
case 0:
|
||||
event = LADDER_START;
|
||||
break;
|
||||
case 1:
|
||||
event = LADDER_MIDDLE;
|
||||
break;
|
||||
case 2:
|
||||
event = LADDER_END;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
PositionedSoundRecord sound = new PositionedSoundRecord(event.getSoundName(), 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);
|
||||
addSound(te.getPos(), sound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMechMBTurningSound(TileEntityMechMB te, MechEnergy energy) {
|
||||
SoundHandler sndHandler = ClientUtils.mc().getSoundHandler();
|
||||
List<ISound> soundsAtPos;
|
||||
if (playingSounds.containsKey(te.getPos())) {
|
||||
soundsAtPos = playingSounds.get(te.getPos());
|
||||
soundsAtPos.removeIf(s -> !sndHandler.isSoundPlaying(s));
|
||||
if (soundsAtPos.isEmpty()) {
|
||||
playingSounds.remove(te.getPos());
|
||||
}
|
||||
} else {
|
||||
soundsAtPos = ImmutableList.of();
|
||||
}
|
||||
boolean hasSlow = false, hasFast = false;
|
||||
for (ISound s:soundsAtPos) {
|
||||
if (s.getSoundLocation().equals(TURN_FAST.getSoundName())) {
|
||||
hasFast = true;
|
||||
} else if (s.getSoundLocation().equals(TURN_SLOW.getSoundName())) {
|
||||
hasSlow = true;
|
||||
}
|
||||
}
|
||||
if (!hasSlow && energy.getVolumeSlow() > 0) {
|
||||
ISound snd = new IWTickableSound(TURN_SLOW, SoundCategory.BLOCKS, energy::getVolumeSlow, energy::getPitch,
|
||||
te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
sndHandler.playSound(snd);
|
||||
addSound(te.getPos(), snd);
|
||||
}
|
||||
if (!hasFast && energy.getVolumeFast() > 0) {
|
||||
ISound snd = new IWTickableSound(TURN_FAST, SoundCategory.BLOCKS, energy::getVolumeFast, energy::getPitch,
|
||||
te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
sndHandler.playSound(snd);
|
||||
addSound(te.getPos(), snd);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMarxBang(TileEntityMarx te, Vec3d pos, float energy) {
|
||||
SoundEvent soundLoc = MARX_BANG;
|
||||
if (energy<0) {
|
||||
energy = -energy;
|
||||
soundLoc = MARX_POP;
|
||||
}
|
||||
PositionedSoundRecord sound = new PositionedSoundRecord(soundLoc.getSoundName(), SoundCategory.BLOCKS, 5*energy, 1,
|
||||
false, 0, ISound.AttenuationType.LINEAR, (float) pos.x, (float) pos.y, (float) pos.z);
|
||||
ClientUtils.mc().getSoundHandler().playSound(sound);
|
||||
addSound(te.getPos(), sound);
|
||||
}
|
||||
|
||||
private void addSound(BlockPos pos, ISound sound) {
|
||||
List<ISound> allForPos = playingSounds.get(pos);
|
||||
if (allForPos==null) {
|
||||
allForPos = new ArrayList<>();
|
||||
}
|
||||
allForPos.add(sound);
|
||||
if (allForPos.size()==1) {
|
||||
playingSounds.put(pos, allForPos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopAllSoundsExcept(BlockPos pos, Set<?> excluded) {
|
||||
if (playingSounds.containsKey(pos)) {
|
||||
SoundHandler manager = Minecraft.getMinecraft().getSoundHandler();
|
||||
List<ISound> sounds = playingSounds.get(pos);
|
||||
List<ISound> toRemove = new ArrayList<>(sounds.size()-excluded.size());
|
||||
for (ISound sound:sounds) {
|
||||
if (!excluded.contains(sound)) {
|
||||
manager.stopSound(sound);
|
||||
toRemove.add(sound);
|
||||
}
|
||||
}
|
||||
sounds.removeAll(toRemove);
|
||||
if (sounds.isEmpty()) {
|
||||
playingSounds.remove(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleplayer() {
|
||||
return Minecraft.getMinecraft().isSingleplayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidTextureSource(ItemStack stack) {
|
||||
if (!super.isValidTextureSource(stack)) {
|
||||
return false;
|
||||
}
|
||||
IBakedModel texModel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack,
|
||||
null, null);
|
||||
TextureAtlasSprite sprite = texModel.getParticleTexture();
|
||||
//noinspection ConstantConditions
|
||||
if (sprite == null || sprite.hasAnimationMetadata()) {
|
||||
return false;
|
||||
}
|
||||
int[][] data = sprite.getFrameTextureData(0);
|
||||
for (int x = 0; x < data.length; x++) {
|
||||
for (int y = 0; y < data[x].length; y++) {
|
||||
if ((data[x][y] >>> 24) != 255) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@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 TileEntityRSPanel) {
|
||||
return new GuiRSPanelConn((TileEntityRSPanel) 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,84 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialwires.client.panelmodel.SmartLightingQuadIW;
|
||||
import malte0811.industrialwires.controlpanel.PanelUtils;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@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++) {
|
||||
PanelUtils.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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import blusunrize.immersiveengineering.api.Lib;
|
||||
import blusunrize.immersiveengineering.common.items.ItemEarmuffs;
|
||||
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
|
||||
import malte0811.industrialwires.IEObjects;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ITickableSound;
|
||||
import net.minecraft.client.audio.PositionedSound;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class IWTickableSound extends PositionedSound implements ITickableSound {
|
||||
private Supplier<Float> getVolume;
|
||||
private Supplier<Float> getPitch;
|
||||
|
||||
protected IWTickableSound(SoundEvent sound, SoundCategory category,
|
||||
Supplier<Float> getVolume, Supplier<Float> getPitch,
|
||||
float xPosF, float yPosF, float zPosF) {
|
||||
super(sound, category);
|
||||
this.getVolume = getVolume;
|
||||
this.getPitch = getPitch;
|
||||
this.repeat = true;
|
||||
this.repeatDelay = 0;
|
||||
this.xPosF = xPosF;
|
||||
this.yPosF = yPosF;
|
||||
this.zPosF = zPosF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDonePlaying() {
|
||||
return getVolume.get()<=0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
//NOP
|
||||
}
|
||||
|
||||
//This can be static as it's the same for all sounds
|
||||
private static float mod = 1;
|
||||
private static long lastCheck = Long.MIN_VALUE;
|
||||
private static final int UPDATE_FREQU = 5;
|
||||
@Override
|
||||
public float getVolume() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
long time = mc.world.getTotalWorldTime();
|
||||
// Earmuffs don't work well for long sounds
|
||||
// so I adjust the volume manually and blacklist the sounds from the "normal" muffling
|
||||
if (time>lastCheck+UPDATE_FREQU) {
|
||||
mod = 1;
|
||||
lastCheck = time;
|
||||
ItemStack earmuffs = mc.player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||
if (ItemNBTHelper.hasKey(earmuffs, Lib.NBT_Earmuffs))
|
||||
earmuffs = ItemNBTHelper.getItemStack(earmuffs, Lib.NBT_Earmuffs);
|
||||
if (!earmuffs.isEmpty() && IEObjects.itemEarmuffs.equals(earmuffs.getItem()) &&
|
||||
!ItemNBTHelper.getBoolean(earmuffs, "IE:Earmuffs:Cat_" + category.getName())) {
|
||||
mod = ItemEarmuffs.getVolumeMod(earmuffs);
|
||||
}
|
||||
}
|
||||
return mod*getVolume.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPitch() {
|
||||
return getPitch.get();
|
||||
}
|
||||
}
|
|
@ -1,26 +1,28 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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;
|
||||
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;
|
||||
|
@ -29,6 +31,7 @@ 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;
|
||||
|
@ -78,10 +81,56 @@ 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,18 +1,32 @@
|
|||
package malte0811.industrialWires.client.gui;
|
||||
/*
|
||||
* 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;
|
||||
|
||||
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.items.ItemPanelComponent;
|
||||
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.network.MessageItemSync;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
@ -29,6 +43,8 @@ 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;
|
||||
|
@ -68,9 +84,9 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
toAdd.setText(sc.value);
|
||||
stringTexts.add(toAdd);
|
||||
}
|
||||
IConfigurableComponent.RSChannelConfig[] rs = confComp.getRSChannelOptions();
|
||||
IConfigurableComponent.RSColorConfig[] rs = confComp.getRSChannelOptions();
|
||||
rsChannelChoosers.clear();
|
||||
for (IConfigurableComponent.RSChannelConfig rc : rs) {
|
||||
for (IConfigurableComponent.RSColorConfig rc : rs) {
|
||||
if (rc.small) {
|
||||
rsChannelChoosers.add(new GuiChannelPickerSmall(0, componentLeft + rc.x, componentTop + rc.y, 10, 40, rc.value));
|
||||
} else {
|
||||
|
@ -272,41 +288,41 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
|
||||
private void sync(int id, String value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setString(ItemPanelComponent.VALUE, value);
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setString(VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, boolean value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setBoolean(ItemPanelComponent.VALUE, value);
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setBoolean(VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, byte value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setByte(ItemPanelComponent.VALUE, value);
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setByte(VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, int value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setInteger(ItemPanelComponent.VALUE, value);
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setInteger(VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, float value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, id);
|
||||
update.setFloat(ItemPanelComponent.VALUE, value);
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(ID, id);
|
||||
update.setFloat(VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
|
@ -314,37 +330,37 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
NBTTagList list = new NBTTagList();
|
||||
for (int i = 0; i < stringTexts.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setString(ItemPanelComponent.VALUE, stringTexts.get(i).getText());
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setString(VALUE, stringTexts.get(i).getText());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0; i < boolButtons.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setBoolean(ItemPanelComponent.VALUE, boolButtons.get(i).state);
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setBoolean(VALUE, boolButtons.get(i).state);
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0; i < rsChannelChoosers.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setByte(ItemPanelComponent.VALUE, rsChannelChoosers.get(i).getSelected());
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setByte(VALUE, rsChannelChoosers.get(i).getSelected());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0; i < intChoosers.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setInteger(ItemPanelComponent.VALUE, intChoosers.get(i).getValue());
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setInteger(VALUE, intChoosers.get(i).getValue());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0; i < floatSliders.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(ItemPanelComponent.TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(ItemPanelComponent.ID, i);
|
||||
update.setFloat(ItemPanelComponent.VALUE, (float) floatSliders.get(i).getValue());
|
||||
update.setInteger(TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(ID, i);
|
||||
update.setFloat(VALUE, (float) floatSliders.get(i).getValue());
|
||||
list.appendTag(update);
|
||||
}
|
||||
sync(list);
|
|
@ -1,33 +1,30 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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 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;
|
||||
|
@ -39,7 +36,10 @@ 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.*;
|
||||
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 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.hasNoTags()) {
|
||||
if (!nbt.isEmpty()) {
|
||||
IndustrialWires.packetHandler.sendToServer(new MessageGUIInteract(container.tile, nbt));
|
||||
}
|
||||
}
|
|
@ -1,28 +1,25 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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 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 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 net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -33,10 +30,10 @@ import net.minecraft.util.ResourceLocation;
|
|||
import java.io.IOException;
|
||||
|
||||
public class GuiRSPanelConn extends GuiContainer {
|
||||
private TileEntityRSPanelConn te;
|
||||
private TileEntityRSPanel te;
|
||||
private GuiIntChooser chooser;
|
||||
|
||||
public GuiRSPanelConn(TileEntityRSPanelConn tile) {
|
||||
public GuiRSPanelConn(TileEntityRSPanel tile) {
|
||||
super(new ContainerRSPanelConn(tile));
|
||||
te = tile;
|
||||
}
|
|
@ -1,26 +1,23 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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 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,4 +1,19 @@
|
|||
package malte0811.industrialWires.client.gui.elements;
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
|
@ -1,22 +1,19 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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.renderer.GlStateManager;
|
|
@ -1,4 +1,19 @@
|
|||
package malte0811.industrialWires.client.gui.elements;
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
|
@ -0,0 +1,252 @@
|
|||
/*
|
||||
* 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.manual;
|
||||
|
||||
import blusunrize.lib.manual.IManualPage;
|
||||
import blusunrize.lib.manual.ManualInstance;
|
||||
import blusunrize.lib.manual.ManualPages;
|
||||
import gnu.trove.map.TIntIntMap;
|
||||
import gnu.trove.map.TIntObjectMap;
|
||||
import gnu.trove.map.hash.TIntIntHashMap;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
|
||||
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 TIntObjectMap<Map<Integer, Page>> specialByAnchor = new TIntObjectHashMap<>();
|
||||
private final TIntObjectMap<Page> specialByPage = new TIntObjectHashMap<>();
|
||||
private final List<List<String>> entry = new ArrayList<>();
|
||||
private final Function<String, String> tokenTransform;
|
||||
private final int lineWidth;
|
||||
private final int linesPerPage;
|
||||
private TIntIntMap pageByAnchor = new TIntIntHashMap();
|
||||
private final Function<String, IManualPage> defaultPage;
|
||||
|
||||
public TextSplitter(Function<String, Integer> w, int lineWidthPixel, int linesPerPage,
|
||||
Function<String, IManualPage> defPage, Function<String, String> tokenTransform) {
|
||||
width = w;
|
||||
this.lineWidth = lineWidthPixel;
|
||||
this.linesPerPage = linesPerPage;
|
||||
this.tokenTransform = tokenTransform;
|
||||
this.defaultPage = defPage;
|
||||
}
|
||||
|
||||
public TextSplitter(ManualInstance m) {
|
||||
this(m.fontRenderer::getStringWidth, 120, 16, s-> new ManualPages.Text(m, s), (s) -> s);
|
||||
}
|
||||
|
||||
public TextSplitter(ManualInstance m, Function<String, String> tokenTransform) {
|
||||
this(m.fontRenderer::getStringWidth, 120, 16,s-> new ManualPages.Text(m, s), tokenTransform);
|
||||
}
|
||||
|
||||
public void clearSpecialByPage() {
|
||||
specialByPage.clear();
|
||||
}
|
||||
|
||||
public void clearSpecialByAnchor() {
|
||||
specialByAnchor.clear();
|
||||
}
|
||||
|
||||
public void addSpecialPage(int ref, int offset, int lines, Function<String, IManualPage> factory) {
|
||||
if (offset < 0 || (ref != -1 && ref < 0)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (!specialByAnchor.containsKey(ref)) {
|
||||
specialByAnchor.put(ref, new HashMap<>());
|
||||
}
|
||||
specialByAnchor.get(ref).put(offset, new Page(lines, factory));
|
||||
}
|
||||
|
||||
// I added labels to all break statements to make it more readable
|
||||
@SuppressWarnings({"UnnecessaryLabelOnBreakStatement", "UnusedLabel"})
|
||||
public void split(String in) {
|
||||
clearSpecialByPage();
|
||||
entry.clear();
|
||||
String[] wordsAndSpaces = splitWhitespace(in);
|
||||
int pos = 0;
|
||||
List<String> overflow = new ArrayList<>();
|
||||
updateSpecials(-1, 0, 0, -1);
|
||||
entry:
|
||||
while (pos < wordsAndSpaces.length) {
|
||||
List<String> page = new ArrayList<>(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 token = tokenTransform.apply(wordsAndSpaces[pos]);
|
||||
int textWidth = getWidth(token);
|
||||
if (currWidth + textWidth < lineWidth || line.length() == 0) {
|
||||
pos++;
|
||||
if (token.equals("<np>")) {
|
||||
page.add(line);
|
||||
break page;
|
||||
} else if (token.equals("<br>")) {
|
||||
break line;
|
||||
} else if (token.startsWith("<&") && token.endsWith(">")) {
|
||||
int id = Integer.parseInt(token.substring(2, token.length() - 1));
|
||||
int pageForId = entry.size();
|
||||
Map<Integer, Page> specialForId = specialByAnchor.get(id);
|
||||
if (specialForId != null && specialForId.containsKey(0)) {
|
||||
if (page.size() >= specialForId.get(0).lines) {
|
||||
pageForId++;
|
||||
}
|
||||
}
|
||||
//New page if there is already a special element on this page
|
||||
if (updateSpecials(id, pageForId, page.size(), entry.size())) {
|
||||
page.add(line);
|
||||
pos--;
|
||||
break page;
|
||||
}
|
||||
} else if (!Character.isWhitespace(token.charAt(0)) || line.length() != 0) {//Don't add whitespace at the start of a line
|
||||
line += token;
|
||||
currWidth += textWidth;
|
||||
}
|
||||
} else {
|
||||
break line;
|
||||
}
|
||||
}
|
||||
line = line.trim();
|
||||
if (!line.isEmpty())
|
||||
page.add(line);
|
||||
}
|
||||
if (!(page.stream().allMatch(String::isEmpty) && pos == wordsAndSpaces.length)) {
|
||||
int linesMax = getLinesOnPage(entry.size());
|
||||
if (page.size() > linesMax) {
|
||||
overflow.addAll(page.subList(linesMax, page.size()));
|
||||
page = page.subList(0, linesMax);
|
||||
}
|
||||
entry.add(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<IManualPage> toManualEntry() {
|
||||
List<IManualPage> ret = new ArrayList<>(entry.size());
|
||||
for (int i = 0; i < entry.size(); i++) {
|
||||
String s = entry.get(i).stream().collect(Collectors.joining("\n"));
|
||||
if (specialByPage.containsKey(i)) {
|
||||
ret.add(specialByPage.get(i).factory.apply(s));
|
||||
} else {
|
||||
ret.add(defaultPage.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 (specialByPage.containsKey(id)) {
|
||||
return specialByPage.get(id).lines;
|
||||
}
|
||||
return linesPerPage;
|
||||
}
|
||||
|
||||
private boolean updateSpecials(int ref, int pageRef, int currLine, int currPage) {
|
||||
if (specialByAnchor.containsKey(ref)) {
|
||||
TIntObjectMap<Page> specialByPageTmp = new TIntObjectHashMap<>();
|
||||
for (Map.Entry<Integer, Page> entry : specialByAnchor.get(ref).entrySet()) {
|
||||
int specialPage = pageRef + entry.getKey();
|
||||
if (specialByPage.containsKey(specialPage)) {
|
||||
return true;
|
||||
}
|
||||
if (entry.getKey()==0 && currPage==pageRef&&entry.getValue().lines<=currLine) {
|
||||
return true;
|
||||
}
|
||||
specialByPageTmp.put(specialPage, entry.getValue());
|
||||
}
|
||||
specialByPage.putAll(specialByPageTmp);
|
||||
} 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");
|
||||
}
|
||||
pageByAnchor.put(ref, pageRef);
|
||||
return false;
|
||||
}
|
||||
|
||||
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[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
private class Page {
|
||||
final int lines;
|
||||
final Function<String, IManualPage> factory;
|
||||
public Page(int l, Function<String, IManualPage> f) {
|
||||
factory = f;
|
||||
lines = l;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
* 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.multiblock_io_model;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEEnums.SideConfig;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import malte0811.industrialwires.blocks.IWProperties;
|
||||
import malte0811.industrialwires.client.ClientUtilsIW;
|
||||
import malte0811.industrialwires.client.RawQuad;
|
||||
import malte0811.industrialwires.util.MBSideConfig;
|
||||
import malte0811.industrialwires.util.MBSideConfig.BlockFace;
|
||||
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.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
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;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BakedMBIOModel implements IBakedModel {
|
||||
private static final MBSideConfig NULL_CONFIG = new MBSideConfig(ImmutableList.of(new BlockFace(new BlockPos(0, 2, 0), EnumFacing.DOWN)));
|
||||
private static final Matrix4 ID = new Matrix4();
|
||||
|
||||
static final ResourceLocation IO_LOC = new ResourceLocation(IndustrialWires.MODID, "blocks/io");
|
||||
static TextureAtlasSprite IO_TEX = null;
|
||||
|
||||
private final IBakedModel base;
|
||||
private final TRSRTransformation transform;
|
||||
|
||||
private final Cache<MBSideConfig, List<BakedQuad>> cache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES)
|
||||
.maximumSize(100).build();
|
||||
|
||||
BakedMBIOModel(IBakedModel base, IModelState transform) {
|
||||
this.base = base;
|
||||
this.transform = TRSRTransformation.blockCornerToCenter(transform.apply(Optional.empty()).orElse(TRSRTransformation.identity()));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
|
||||
if (side != null)
|
||||
return ImmutableList.of();
|
||||
MBSideConfig config = NULL_CONFIG;
|
||||
if (state instanceof IExtendedBlockState) {
|
||||
MBSideConfig tmpConfig = ((IExtendedBlockState) state).getValue(IWProperties.MB_SIDES);
|
||||
if (tmpConfig!=null) {
|
||||
config = tmpConfig;
|
||||
}
|
||||
}
|
||||
List<BakedQuad> ret = cache.getIfPresent(config);
|
||||
if (ret==null) {
|
||||
if (IO_TEX==null) {
|
||||
IO_TEX = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(IO_LOC.toString());
|
||||
}
|
||||
Matrix4 mat = new Matrix4(transform.getMatrix());
|
||||
ret = new ArrayList<>(base.getQuads(state, side, rand));
|
||||
for (Map.Entry<BlockFace, SideConfig> f:config.sides.entrySet()) {
|
||||
if (f.getKey().face==null) {
|
||||
continue;
|
||||
}
|
||||
Vec3d transformedPos = mat.apply(new Vec3d(f.getKey().offset));
|
||||
EnumFacing transformedFace = transform.rotate(f.getKey().face);
|
||||
Vector3f[] verts = getVerticesFromFace(transformedPos, transformedFace);
|
||||
RawQuad q = new RawQuad(verts[0], verts[1], verts[2], verts[3], transformedFace,
|
||||
IO_TEX, new float[]{1, 1, 1, 1}, getNormal(transformedFace),
|
||||
getUVsForConfig(f.getValue()));
|
||||
ret.add(ClientUtilsIW.bakeQuad(q, ID, ID));
|
||||
}
|
||||
ret = ImmutableList.copyOf(ret);
|
||||
cache.put(config.copy(), ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static final Vector3f[] NORMALS = new Vector3f[6];
|
||||
private static final Vector3f[][] VERTICES = new Vector3f[6][4];
|
||||
static {
|
||||
final float innerSize = .5F;
|
||||
final float offsetInner = 1-innerSize/2;
|
||||
float[] vec = new float[3];
|
||||
for (int i = 0; i < EnumFacing.VALUES.length; i++) {
|
||||
EnumFacing f = EnumFacing.VALUES[i];
|
||||
NORMALS[i] = new Vector3f(f.getXOffset(), f.getYOffset(), f.getZOffset());
|
||||
int axis = f.getAxis().ordinal();
|
||||
vec[axis] = f.getAxisDirection()==EnumFacing.AxisDirection.POSITIVE?1.001F:-.001F;
|
||||
float x1 = f.getAxisDirection()==EnumFacing.AxisDirection.POSITIVE?offsetInner:1-offsetInner;
|
||||
for (int j = 0;j<4;j++) {
|
||||
vec[(axis+1)%3] = 0<j&&j<3?x1:1-x1;
|
||||
vec[(axis+2)%3] = j<2?1-offsetInner:offsetInner;
|
||||
VERTICES[i][j] = vecFromArray(vec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector3f vecFromArray(float[] in) {
|
||||
return new Vector3f(in[0], in[1], in[2]);
|
||||
}
|
||||
|
||||
private Vector3f[] getVerticesFromFace(Vec3d p, EnumFacing f) {
|
||||
Vector3f[] orig = VERTICES[f.ordinal()];
|
||||
Vector3f[] ret = new Vector3f[4];
|
||||
Vector3f offset = new Vector3f((float) p.x, (float) p.y, (float) p.z);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ret[i] = Vector3f.add(orig[i], offset, null);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private float[] getUVsForConfig(SideConfig sc) {
|
||||
float u = (sc.ordinal()/2)*8, v = (sc.ordinal()%2)*8;
|
||||
return new float[]{u, v, u+8, v+8};
|
||||
}
|
||||
|
||||
private Vector3f getNormal(EnumFacing face) {
|
||||
return NORMALS[face.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return base.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
return base.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return base.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return base.getParticleTexture();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return base.getOverrides();
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
cache.invalidateAll();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* 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.multiblock_io_model;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEApi;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import malte0811.industrialwires.IndustrialWires;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ICustomModelLoader;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static net.minecraftforge.fml.relauncher.Side.CLIENT;
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
public class MBIOModelLoader implements ICustomModelLoader {
|
||||
private static final Set<BakedMBIOModel> activeModels = new HashSet<>();
|
||||
static {
|
||||
IEApi.renderCacheClearers.add(()-> {
|
||||
for (BakedMBIOModel m:activeModels) {
|
||||
m.clearCache();
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public boolean accepts(@Nonnull ResourceLocation modelLocation) {
|
||||
return IndustrialWires.MODID.equals(modelLocation.getNamespace())
|
||||
&& "models/block/mbio".equals(modelLocation.getPath());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModel loadModel(@Nonnull ResourceLocation modelLocation) throws Exception {
|
||||
return new MBIOModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) {
|
||||
activeModels.clear();
|
||||
BakedMBIOModel.IO_TEX = null;
|
||||
}
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
private static class MBIOModel implements IModel {
|
||||
private static final Collection<ResourceLocation> TEXTURES = ImmutableList.of(
|
||||
BakedMBIOModel.IO_LOC
|
||||
);
|
||||
private ResourceLocation baseModel = new ResourceLocation(IndustrialWires.MODID, "missing");
|
||||
private ImmutableMap<String, String> custom = ImmutableMap.of();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies() {
|
||||
return ImmutableList.of(baseModel);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures() {
|
||||
return TEXTURES;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@SideOnly(CLIENT)
|
||||
public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format,
|
||||
@Nonnull Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
|
||||
try {
|
||||
IModel baseBaked = ModelLoaderRegistry.getModel(baseModel);
|
||||
baseBaked = baseBaked.process(custom);
|
||||
IBakedModel baked = baseBaked.bake(state, format, bakedTextureGetter);
|
||||
BakedMBIOModel ret = new BakedMBIOModel(baked, state);
|
||||
activeModels.add(ret);
|
||||
return ret;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ModelLoaderRegistry.getMissingModel().bake(state, format, bakedTextureGetter);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModel process(ImmutableMap<String, String> customData) {
|
||||
MBIOModel ret = new MBIOModel();
|
||||
String bm = customData.get("base_model");
|
||||
ret.baseModel = new ResourceLocation(bm.substring(1, bm.length()-1));
|
||||
ret.custom = customData;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,33 +1,30 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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 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;
|
||||
|
@ -36,6 +33,8 @@ 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;
|
||||
|
@ -45,6 +44,7 @@ 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,26 +1,23 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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 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;
|
||||
|
@ -50,13 +47,13 @@ public class PanelModelLoader implements ICustomModelLoader {
|
|||
|
||||
@Override
|
||||
public boolean accepts(@Nonnull ResourceLocation modelLocation) {
|
||||
return modelLocation.getResourcePath().contains(RESOURCE_BASE + RESOURCE_LOCATION);
|
||||
return modelLocation.getPath().contains(RESOURCE_BASE + RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModel loadModel(@Nonnull ResourceLocation modelLocation) throws IOException {
|
||||
String resourcePath = modelLocation.getResourcePath();
|
||||
String resourcePath = modelLocation.getPath();
|
||||
int pos = resourcePath.indexOf(RESOURCE_LOCATION);
|
||||
if (pos >= 0) {
|
||||
return new PanelModelBase();
|
|
@ -1,26 +1,23 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* 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 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;
|
||||
|
@ -94,10 +91,10 @@ public class RawModelFontRenderer extends FontRenderer {
|
|||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
super.onResourceManagerReload(resourceManager);
|
||||
String p = locationFontTexture.getResourcePath();
|
||||
String p = locationFontTexture.getPath();
|
||||
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.getResourceDomain() + ":" + p;
|
||||
String f = locationFontTexture.getNamespace() + ":" + p;
|
||||
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(f);
|
||||
}
|
||||
|
|
@ -1,4 +1,19 @@
|
|||
package malte0811.industrialWires.client.panelmodel;
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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.render;
|
||||
|
||||
import blusunrize.immersiveengineering.client.ClientUtils;
|
||||
import malte0811.industrialwires.entities.EntityBrokenPart;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class EntityRenderBrokenPart extends Render<EntityBrokenPart> {
|
||||
public EntityRenderBrokenPart(RenderManager renderManager) {
|
||||
super(renderManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(@Nonnull EntityBrokenPart entity, double x, double y, double z, float entityYaw, float partialTicks) {
|
||||
GlStateManager.pushMatrix();
|
||||
AxisAlignedBB aabb = entity.getEntityBoundingBox();
|
||||
ClientUtils.bindAtlas();
|
||||
Tessellator tes = Tessellator.getInstance();
|
||||
BufferBuilder bb = tes.getBuffer();
|
||||
bb.setTranslation(x - entity.lastTickPosX, y - entity.lastTickPosY, z - entity.lastTickPosZ);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
bb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
TextureAtlasSprite tex = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(entity.texture.toString());
|
||||
ClientUtils.renderTexturedBox(bb, aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ,
|
||||
tex.getMinU(), tex.getMinV(), tex.getInterpolatedU(8), tex.getInterpolatedV(8));
|
||||
tes.draw();
|
||||
bb.setTranslation(0, 0, 0);
|
||||
GlStateManager.popMatrix();
|
||||
super.doRender(entity, x, y, z, entityYaw, partialTicks);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(@Nonnull EntityBrokenPart entity) {
|
||||
return entity.texture;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue