Compare commits

...

6 Commits

Author SHA1 Message Date
thatsIch de069980ce Closes #1287: Set release channel to stable 2015-05-03 22:10:13 +02:00
thatsIch 1710894edc Use self compiled InvTweaks API 2015-05-03 21:23:54 +02:00
thatsIch 65d0ae9290 Merge pull request #1323 from thatsIch/e-installable-mods
Makes maven dependencies de- and installable
2015-05-03 16:24:34 +02:00
thatsIch 1baed48b0a Merge pull request #1372 from thatsIch/b-1368-vibration-chamber-comparator
Fixes #1368: Vibration Chamber notifies neighbors on inventory change and state change
2015-05-03 16:24:26 +02:00
thatsIch 013c8d882c Makes maven dependencies de- and installable
Provides a new configuration `mods` which can be used on Maven Artifacts. That way, we can install them without affecting them on runtime (less load time)

Put the optional tasks into `optional.gradle` where a install task is just a copy task and the deinstall task a delete task

Added maven local to the repositories, if for some reason somebody uses a local maven
2015-05-02 19:35:34 +02:00
thatsIch e392ecd08d Fixes #1368: Vibration Chamber notifies neighbors on inventory change and state change 2015-05-01 17:58:59 +02:00
14 changed files with 324 additions and 105 deletions
+2
View File
@@ -22,9 +22,11 @@ apply from: 'gradle/scripts/dependencies.gradle'
apply from: 'gradle/scripts/artifacts.gradle' apply from: 'gradle/scripts/artifacts.gradle'
apply from: 'gradle/scripts/autoinstallruntime.gradle' apply from: 'gradle/scripts/autoinstallruntime.gradle'
apply from: 'gradle/scripts/integration.gradle' apply from: 'gradle/scripts/integration.gradle'
apply from: 'gradle/scripts/optional.gradle'
buildscript { buildscript {
repositories { repositories {
mavenLocal()
mavenCentral() mavenCentral()
maven { maven {
+26 -9
View File
@@ -1,5 +1,5 @@
aeversion=rv2 aeversion=rv2
aechannel=beta aechannel=stable
aebuild=0 aebuild=0
aegroup=appeng aegroup=appeng
aebasename=appliedenergistics2 aebasename=appliedenergistics2
@@ -11,7 +11,23 @@ minecraft_version=1.7.10
forge_version=10.13.2.1291 forge_version=10.13.2.1291
######################################################### #########################################################
# APIs used for development # # Installable #
#########################################################
waila_version=1.5.10
jabba_version=1.2.1a
enderstorage_version=1.4.7.33
translocator_version=1.1.1.14
ic2_version=2.2.717
enderio_version=2.3.0.375_beta
#cofhlib_version=1.0.1-157
#cofhcore_version=3.0.2-270
#texpansion_version=4.0.0-176
#tfoundation_version=1.0.0-82
betterstorage_version=0.11.3.123.20
invtweaks_version=1.58
#########################################################
# Provided APIs #
######################################################### #########################################################
fmp_version=1.1.1.324 fmp_version=1.1.1.324
code_chicken_lib_version=1.1.3.127 code_chicken_lib_version=1.1.3.127
@@ -20,21 +36,22 @@ nei_version=1.0.4.90
bc_version=6.4.6 bc_version=6.4.6
######################################################### #########################################################
# API Stubs # # Self Compiled APIs #
#########################################################
mekansim_version=8.0.1.198
rotarycraft_version=V5c
#########################################################
# Self Compiled API Stubs #
# Note: Do not edit these version numbers as they are # # Note: Do not edit these version numbers as they are #
# not the version of the mod, but stub code for AE2 to # # not the version of the mod, but stub code for AE2 to #
# compile # # compile #
######################################################### #########################################################
api_betterstorage_version=1
api_coloredlightscore_version=1 api_coloredlightscore_version=1
api_craftguide_version=1 api_craftguide_version=1
api_ic2_version=1
api_immibis_version=1 api_immibis_version=1
api_invtweaks_version=1
api_mekansim_version=1.7.10-8.0.1.198
api_mfr_version=1 api_mfr_version=1
api_railcraft_version=1 api_railcraft_version=1
api_rblocks_version=1 api_rblocks_version=1
api_rf_version=2 api_rf_version=2
api_rotarycraft_version=V5c
api_waila_version=1.5.10_1.7.10
+65 -10
View File
@@ -19,14 +19,14 @@
repositories { repositories {
mavenLocal()
maven { maven {
name 'CB Maven FS' name "ChickenBones"
url "http://chickenbones.net/maven/" url "http://chickenbones.net/maven/"
} }
maven { maven {
name "Waila Mobius Repo" name "Mobius"
url "http://mobiusstrip.eu/maven" url "http://mobiusstrip.eu/maven"
} }
@@ -34,31 +34,86 @@ repositories {
name "FireBall API Depot" name "FireBall API Depot"
url "http://dl.tsr.me/artifactory/libs-release-local" url "http://dl.tsr.me/artifactory/libs-release-local"
} }
maven {
name = "Player"
url = "http://maven.ic2.player.to/"
}
maven {
name = "Tterrag"
url = "http://maven.tterrag.com/"
}
maven {
name = "RX14 Proxy"
url = "http://mvn.rx14.co.uk/repo/"
}
// CurseForge DNS for TE is not available or I am just being unlucky, code part can stay since this is applicable to any other curseforge mod though
// ivy {
// name = "CoFHLib"
// artifactPattern "http://addons.cursecdn.com/files/2212/893/[module]-[revision].[ext]"
// }
//
// ivy {
// name = "CoFHCore"
// artifactPattern "http://addons.cursecdn.com/files/2212/895/[module]-[revision].[ext]"
// }
// ivy {
// name = "ThermalExpansion"
// artifactPattern "http://addons.curse.cursecdn.com/files/2212/446/[module]-[revision].[ext]"
// }
// ivy {
// name = "ThermalFoundation"
// artifactPattern "http://addons.curse.cursecdn.com/files/2212/444/[module]-[revision].[ext]"
// }
}
configurations {
mods
} }
dependencies { dependencies {
// installable
mods "mcp.mobius.waila:Waila:${waila_version}_${minecraft_version}:dev"
mods "mcp.mobius.jabba:Jabba:${jabba_version}_${minecraft_version}:dev"
mods "codechicken:EnderStorage:${minecraft_version}-${enderstorage_version}:dev"
mods "codechicken:Translocator:${minecraft_version}-${translocator_version}:dev"
mods "net.industrial-craft:industrialcraft-2:${ic2_version}-experimental:dev"
mods "com.enderio:EnderIO:${minecraft_version}-${enderio_version}:dev"
mods "net.mcft.copy.betterstorage:BetterStorage:${minecraft_version}-${betterstorage_version}:deobf"
mods "inventorytweaks:InventoryTweaks:${invtweaks_version}:deobf"
// mods name: 'CoFHLib', version: "[${minecraft_version}]${cofhlib_version}-dev", ext: 'jar'
// mods name: 'CoFHCore', version: "[${minecraft_version}]${cofhcore_version}-dev", ext: 'jar'
// mods name: 'ThermalExpansion', version: "[${minecraft_version}]${texpansion_version}-dev", ext: 'jar'
// mods name: 'ThermalFoundation', version: "[${minecraft_version}]${tfoundation_version}-dev", ext: 'jar'
compile "codechicken:ForgeMultipart:${minecraft_version}-${fmp_version}:dev" compile "codechicken:ForgeMultipart:${minecraft_version}-${fmp_version}:dev"
compile "codechicken:CodeChickenLib:${minecraft_version}-${code_chicken_lib_version}:dev" compile "codechicken:CodeChickenLib:${minecraft_version}-${code_chicken_lib_version}:dev"
compile "codechicken:CodeChickenCore:${minecraft_version}-${code_chicken_core_version}:dev" compile "codechicken:CodeChickenCore:${minecraft_version}-${code_chicken_core_version}:dev"
compile "codechicken:NotEnoughItems:${minecraft_version}-${nei_version}:dev" compile "codechicken:NotEnoughItems:${minecraft_version}-${nei_version}:dev"
compile "com.mod-buildcraft:buildcraft:${bc_version}:dev" compile "com.mod-buildcraft:buildcraft:${bc_version}:dev"
// provided APIs
compile "net.industrial-craft:industrialcraft-2:${ic2_version}-experimental:api"
compile "net.mcft.copy.betterstorage:BetterStorage:${minecraft_version}-${betterstorage_version}:api"
// self compiled APIs // self compiled APIs
compile(group: 'api', name: 'betterstorage', version: "${api_betterstorage_version}") compile "appeng:Waila:${waila_version}_${minecraft_version}:api"
compile "appeng:RotaryCraft:${rotarycraft_version}:api"
compile "appeng:mekanism:${minecraft_version}-${mekansim_version}:api"
compile "appeng:InventoryTweaks:${invtweaks_version}:api"
// self compiled stubs
compile(group: 'api', name: 'coloredlightscore', version: "${api_coloredlightscore_version}") compile(group: 'api', name: 'coloredlightscore', version: "${api_coloredlightscore_version}")
compile(group: 'api', name: 'craftguide', version: "${api_craftguide_version}") compile(group: 'api', name: 'craftguide', version: "${api_craftguide_version}")
compile(group: 'api', name: 'ic2', version: "${api_ic2_version}")
compile(group: 'api', name: 'immibis', version: "${api_immibis_version}") compile(group: 'api', name: 'immibis', version: "${api_immibis_version}")
compile(group: 'api', name: 'invtweaks', version: "${api_invtweaks_version}")
compile(group: 'api', name: 'mfr', version: "${api_mfr_version}") compile(group: 'api', name: 'mfr', version: "${api_mfr_version}")
compile(group: 'api', name: 'railcraft', version: "${api_railcraft_version}") compile(group: 'api', name: 'railcraft', version: "${api_railcraft_version}")
compile(group: 'api', name: 'rblocks', version: "${api_rblocks_version}") compile(group: 'api', name: 'rblocks', version: "${api_rblocks_version}")
compile(group: 'api', name: 'rf', version: "${api_rf_version}") compile(group: 'api', name: 'rf', version: "${api_rf_version}")
compile "appeng:Waila:${api_waila_version}:api"
compile "appeng:RotaryCraft:${api_rotarycraft_version}:api"
compile "appeng:mekanism:${api_mekansim_version}:api"
testCompile "junit:junit:4.11" testCompile "junit:junit:4.11"
} }
+106
View File
@@ -0,0 +1,106 @@
task wrapper(type: Wrapper) {
gradleVersion = "2.3"
}
// WAILA
task installWaila(type: Copy, dependsOn: "deinstallWaila") {
from { configurations.mods }
include "**/*Waila*dev.jar"
into file(minecraft.runDir + "/mods")
}
task deinstallWaila(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*Waila*.jar")
}
// JABBA
task installJabba(type: Copy, dependsOn: "deinstallJabba") {
from { configurations.mods }
include "**/*Jabba*dev.jar"
into file(minecraft.runDir + "/mods")
}
task deinstallJabba(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*Jabba*.jar")
}
// ENDER STORAGE
task installEnderStorage(type: Copy, dependsOn: "deinstallEnderStorage") {
from { configurations.mods }
include "**/*EnderStorage*dev.jar"
into file(minecraft.runDir + "/mods")
}
task deinstallEnderStorage(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*EnderStorage*.jar")
}
// TRANSLOCATOR
task installTranslocator(type: Copy, dependsOn: "deinstallTranslocator") {
from { configurations.mods }
include "**/*Translocator*dev.jar"
into file(minecraft.runDir + "/mods")
}
task deinstallTranslocator(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*Translocator*.jar")
}
// INDUSTRIALCRAFT
task installIC2(type: Copy, dependsOn: "deinstallIC2") {
from { configurations.mods }
include "**/*industrialcraft*dev.jar"
into file(minecraft.runDir + "/mods")
}
task deinstallIC2(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*industrialcraft*.jar")
}
// ENDER IO
task installEnderIO(type: Copy, dependsOn: "deinstallEnderIO") {
from { configurations.mods }
include "**/*EnderIO*dev.jar"
into file(minecraft.runDir + "/mods")
}
task deinstallEnderIO(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*EnderIO*.jar")
}
// TE
//task installTE(type: Copy, dependsOn: "deinstallTE") {
// from { configurations.mods }
// include "**/*CoFHLib*.jar"
// include "**/*CoFHCore*.jar"
// include "**/*ThermalFoundation*.jar"
// include "**/*ThermalExpansion*.jar"
//
// into file(minecraft.runDir + "/mods")
//}
//
//task deinstallTE(type: Delete) {
// delete fileTree(dir: minecraft.runDir + "/mods", includes: ["*CoFHLib*.jar", "*CoFHCore*.jar", "*ThermalFoundation*.jar", "*ThermalExpansion*.jar"])
//}
// INV TWEAKS
task installInvTweaks(type: Copy, dependsOn: "deinstallInvTweaks") {
from { configurations.mods }
include "**/*InventoryTweaks*dev*.jar"
into file(minecraft.runDir + "/mods")
}
task deinstallInvTweaks(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*InventoryTweaks*.jar")
}
// BETTER STORAGE
task installBetterStorage(type: Copy, dependsOn: "deinstallBetterStorage") {
from { configurations.mods }
include "**/*BetterStorage*deobf*.jar"
into file(minecraft.runDir + "/mods")
}
task deinstallBetterStorage(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*BetterStorage*.jar")
}
Binary file not shown.
+2 -2
View File
@@ -1,6 +1,6 @@
#Sat Sep 13 21:58:22 CEST 2014 #Sat May 02 19:28:20 CEST 2015
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip
@@ -39,7 +39,7 @@ import appeng.tile.misc.TileVibrationChamber;
import appeng.util.Platform; import appeng.util.Platform;
public class BlockVibrationChamber extends AEBaseBlock public final class BlockVibrationChamber extends AEBaseBlock
{ {
public BlockVibrationChamber() public BlockVibrationChamber()
+1 -1
View File
@@ -11,7 +11,7 @@ import java.lang.annotation.Target;
* Marker interface to help identify invocation of reflection * Marker interface to help identify invocation of reflection
*/ */
@Retention( RetentionPolicy.SOURCE ) @Retention( RetentionPolicy.SOURCE )
@Target( { ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.TYPE } ) @Target( { ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.TYPE, ElementType.METHOD } )
public @interface Reflected public @interface Reflected
{ {
+3 -1
View File
@@ -19,6 +19,8 @@
package appeng.tile; package appeng.tile;
import javax.annotation.Nullable;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
@@ -93,7 +95,7 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor
} }
@Override @Override
public void setInventorySlotContents( int i, ItemStack itemstack ) public void setInventorySlotContents( int i, @Nullable ItemStack itemstack )
{ {
this.getInternalInventory().setInventorySlotContents( i, itemstack ); this.getInternalInventory().setInventorySlotContents( i, itemstack );
} }
+69 -40
View File
@@ -26,6 +26,9 @@ import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
@@ -61,14 +64,15 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
{ {
public static final ThreadLocal<WeakReference<AEBaseTile>> DROP_NO_ITEMS = new ThreadLocal<WeakReference<AEBaseTile>>(); public static final ThreadLocal<WeakReference<AEBaseTile>> DROP_NO_ITEMS = new ThreadLocal<WeakReference<AEBaseTile>>();
private static final HashMap<Class, EnumMap<TileEventType, List<AETileEventHandler>>> HANDLERS = new HashMap<Class, EnumMap<TileEventType, List<AETileEventHandler>>>(); private static final Map<Class<? extends AEBaseTile>, Map<TileEventType, List<AETileEventHandler>>> HANDLERS = new HashMap<Class<? extends AEBaseTile>, Map<TileEventType, List<AETileEventHandler>>>();
private static final HashMap<Class, ItemStackSrc> ITEM_STACKS = new HashMap<Class, ItemStackSrc>(); private static final Map<Class<? extends TileEntity>, ItemStackSrc> ITEM_STACKS = new HashMap<Class<? extends TileEntity>, ItemStackSrc>();
public int renderFragment = 0; private int renderFragment = 0;
@Nullable
public String customName; public String customName;
private ForgeDirection forward = ForgeDirection.UNKNOWN; private ForgeDirection forward = ForgeDirection.UNKNOWN;
private ForgeDirection up = ForgeDirection.UNKNOWN; private ForgeDirection up = ForgeDirection.UNKNOWN;
public static void registerTileItem( Class c, ItemStackSrc wat ) public static void registerTileItem( Class<? extends TileEntity> c, ItemStackSrc wat )
{ {
ITEM_STACKS.put( c, wat ); ITEM_STACKS.put( c, wat );
} }
@@ -84,11 +88,13 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
return !this.worldObj.blockExists( this.xCoord, this.yCoord, this.zCoord ); return !this.worldObj.blockExists( this.xCoord, this.yCoord, this.zCoord );
} }
@Nonnull
public TileEntity getTile() public TileEntity getTile()
{ {
return this; return this;
} }
@Nullable
protected ItemStack getItemFromTile( Object obj ) protected ItemStack getItemFromTile( Object obj )
{ {
ItemStackSrc src = ITEM_STACKS.get( obj.getClass() ); ItemStackSrc src = ITEM_STACKS.get( obj.getClass() );
@@ -99,11 +105,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
return src.stack( 1 ); return src.stack( 1 );
} }
public final void Tick()
{
}
/** /**
* for dormant chunk cache. * for dormant chunk cache.
*/ */
@@ -176,7 +177,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
{ {
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.TICK ) ) for( AETileEventHandler h : this.getHandlerListFor( TileEventType.TICK ) )
{ {
h.Tick( this ); h.tick( this );
} }
} }
@@ -211,10 +212,11 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
return this.hasHandlerFor( TileEventType.TICK ); return this.hasHandlerFor( TileEventType.TICK );
} }
protected boolean hasHandlerFor( TileEventType type ) private boolean hasHandlerFor( TileEventType type )
{ {
List<AETileEventHandler> list = this.getHandlerListFor( type ); List<AETileEventHandler> list = this.getHandlerListFor( type );
return list != null && !list.isEmpty();
return !list.isEmpty();
} }
@Override @Override
@@ -331,45 +333,72 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
return true; return true;
} }
protected List<AETileEventHandler> getHandlerListFor( TileEventType type ) @Nonnull
private List<AETileEventHandler> getHandlerListFor( TileEventType type )
{ {
Class clz = this.getClass(); final Map<TileEventType, List<AETileEventHandler>> eventToHandlers = this.getEventToHandlers();
EnumMap<TileEventType, List<AETileEventHandler>> handlerSet = HANDLERS.get( clz ); final List<AETileEventHandler> handlers = this.getHandlers( eventToHandlers, type );
if( handlerSet == null ) return handlers;
{
HANDLERS.put( clz, handlerSet = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class ) );
for( Method m : clz.getMethods() )
{
TileEvent te = m.getAnnotation( TileEvent.class );
if( te != null )
{
this.addHandler( handlerSet, te.value(), m );
}
}
}
List<AETileEventHandler> list = handlerSet.get( type );
if( list == null )
{
handlerSet.put( type, list = new LinkedList<AETileEventHandler>() );
}
return list;
} }
private void addHandler( EnumMap<TileEventType, List<AETileEventHandler>> handlerSet, TileEventType value, Method m ) @Nonnull
private Map<TileEventType, List<AETileEventHandler>> getEventToHandlers()
{
final Class<? extends AEBaseTile> clazz = this.getClass();
final Map<TileEventType, List<AETileEventHandler>> storedHandlers = HANDLERS.get( clazz );
if ( storedHandlers == null )
{
final Map<TileEventType, List<AETileEventHandler>> newStoredHandlers = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class );
HANDLERS.put( clazz, newStoredHandlers );
for( Method method : clazz.getMethods() )
{
TileEvent event = method.getAnnotation( TileEvent.class );
if( event != null )
{
this.addHandler( newStoredHandlers, event.value(), method );
}
}
return newStoredHandlers;
}
else
{
return storedHandlers;
}
}
@Nonnull
private List<AETileEventHandler> getHandlers( Map<TileEventType, List<AETileEventHandler>> eventToHandlers, TileEventType event ) {
final List<AETileEventHandler> oldHandlers = eventToHandlers.get( event );
if( oldHandlers == null )
{
final List<AETileEventHandler> newHandlers = new LinkedList<AETileEventHandler>();
eventToHandlers.put( event, newHandlers );
return newHandlers;
}
else
{
return oldHandlers;
}
}
private void addHandler( Map<TileEventType, List<AETileEventHandler>> handlerSet, TileEventType value, Method m )
{ {
List<AETileEventHandler> list = handlerSet.get( value ); List<AETileEventHandler> list = handlerSet.get( value );
if( list == null ) if( list == null )
{ {
handlerSet.put( value, list = new ArrayList<AETileEventHandler>() ); list = new ArrayList<AETileEventHandler>();
handlerSet.put( value, list );
} }
list.add( new AETileEventHandler( m, value ) ); list.add( new AETileEventHandler( m ) );
} }
@Override @Override
@@ -32,18 +32,18 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.tile.AEBaseTile; import appeng.tile.AEBaseTile;
public class AETileEventHandler public final class AETileEventHandler
{ {
private final Method method; private final Method method;
public AETileEventHandler( Method m, TileEventType which ) public AETileEventHandler( Method method )
{ {
this.method = m; this.method = method;
} }
// TICK // TICK
public void Tick( AEBaseTile tile ) public void tick( AEBaseTile tile )
{ {
try try
{ {
@@ -25,5 +25,10 @@ public enum TileEventType
WORLD_NBT_READ, WORLD_NBT_WRITE, WORLD_NBT_READ, WORLD_NBT_WRITE,
NETWORK_READ, NETWORK_WRITE /**
* Methods annotated with this need to return a boolean
*/
NETWORK_READ,
NETWORK_WRITE
} }
@@ -36,21 +36,25 @@ import appeng.api.networking.ticking.TickingRequest;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.core.settings.TickRates; import appeng.core.settings.TickRates;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.tile.TileEvent; import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType; import appeng.tile.events.TileEventType;
import appeng.tile.grid.AENetworkInvTile; import appeng.tile.grid.AENetworkInvTile;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation; import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
public class TileVibrationChamber extends AENetworkInvTile implements IGridTickable public class TileVibrationChamber extends AENetworkInvTile implements IGridTickable
{ {
private static final int FUEL_SLOT_INDEX = 0;
final double powerPerTick = 5; private static final double POWER_PER_TICK = 5;
private static final int[] ACCESSIBLE_SLOTS = new int[] { FUEL_SLOT_INDEX };
final int[] sides = new int[] { 0 }; private static final int MAX_BURN_SPEED = 200;
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 ); private static final double DILATION_SCALING = 100.0;
private static final int MIN_BURN_SPEED = 20;
private final IInventory inv = new AppEngInternalInventory( this, 1 );
public int burnSpeed = 100; public int burnSpeed = 100;
public double burnTime = 0; public double burnTime = 0;
@@ -71,16 +75,20 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
return AECableType.COVERED; return AECableType.COVERED;
} }
@Reflected
@TileEvent( TileEventType.NETWORK_READ ) @TileEvent( TileEventType.NETWORK_READ )
public boolean readFromStream_TileVibrationChamber( ByteBuf data ) public boolean hasUpdate( ByteBuf data )
{ {
boolean wasOn = this.isOn; final boolean wasOn = this.isOn;
this.isOn = data.readBoolean(); this.isOn = data.readBoolean();
return wasOn != this.isOn; // TESR doesn't need updates! return wasOn != this.isOn; // TESR doesn't need updates!
} }
@Reflected
@TileEvent( TileEventType.NETWORK_WRITE ) @TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TileVibrationChamber( ByteBuf data ) public void writeToNetwork( ByteBuf data )
{ {
data.writeBoolean( this.burnTime > 0 ); data.writeBoolean( this.burnTime > 0 );
} }
@@ -107,12 +115,6 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
return this.inv; return this.inv;
} }
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override @Override
public boolean isItemValidForSlot( int i, ItemStack itemstack ) public boolean isItemValidForSlot( int i, ItemStack itemstack )
{ {
@@ -147,12 +149,12 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
@Override @Override
public int[] getAccessibleSlotsBySide( ForgeDirection side ) public int[] getAccessibleSlotsBySide( ForgeDirection side )
{ {
return this.sides; return ACCESSIBLE_SLOTS;
} }
private boolean canEatFuel() private boolean canEatFuel()
{ {
ItemStack is = this.getStackInSlot( 0 ); ItemStack is = this.getStackInSlot( FUEL_SLOT_INDEX );
if( is != null ) if( is != null )
{ {
int newBurnTime = TileEntityFurnace.getItemBurnTime( is ); int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
@@ -182,7 +184,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
} }
@Override @Override
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall )
{ {
if( this.burnTime <= 0 ) if( this.burnTime <= 0 )
{ {
@@ -197,10 +199,10 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
return TickRateModulation.SLEEP; return TickRateModulation.SLEEP;
} }
this.burnSpeed = Math.max( 20, Math.min( this.burnSpeed, 200 ) ); this.burnSpeed = Math.max( MIN_BURN_SPEED, Math.min( this.burnSpeed, MAX_BURN_SPEED ) );
double dilation = this.burnSpeed / 100.0; double dilation = this.burnSpeed / DILATION_SCALING;
double timePassed = TicksSinceLastCall * dilation; double timePassed = ticksSinceLastCall * dilation;
this.burnTime -= timePassed; this.burnTime -= timePassed;
if( this.burnTime < 0 ) if( this.burnTime < 0 )
{ {
@@ -211,7 +213,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
try try
{ {
IEnergyGrid grid = this.gridProxy.getEnergy(); IEnergyGrid grid = this.gridProxy.getEnergy();
double newPower = timePassed * this.powerPerTick; double newPower = timePassed * POWER_PER_TICK;
double overFlow = grid.injectPower( newPower, Actionable.SIMULATE ); double overFlow = grid.injectPower( newPower, Actionable.SIMULATE );
// burn the over flow. // burn the over flow.
@@ -219,30 +221,30 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
if( overFlow > 0 ) if( overFlow > 0 )
{ {
this.burnSpeed -= TicksSinceLastCall; this.burnSpeed -= ticksSinceLastCall;
} }
else else
{ {
this.burnSpeed += TicksSinceLastCall; this.burnSpeed += ticksSinceLastCall;
} }
this.burnSpeed = Math.max( 20, Math.min( this.burnSpeed, 200 ) ); this.burnSpeed = Math.max( MIN_BURN_SPEED, Math.min( this.burnSpeed, MAX_BURN_SPEED ) );
return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER; return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER;
} }
catch( GridAccessException e ) catch( GridAccessException e )
{ {
this.burnSpeed -= TicksSinceLastCall; this.burnSpeed -= ticksSinceLastCall;
this.burnSpeed = Math.max( 20, Math.min( this.burnSpeed, 200 ) ); this.burnSpeed = Math.max( MIN_BURN_SPEED, Math.min( this.burnSpeed, MAX_BURN_SPEED ) );
return TickRateModulation.SLOWER; return TickRateModulation.SLOWER;
} }
} }
private void eatFuel() private void eatFuel()
{ {
ItemStack is = this.getStackInSlot( 0 ); final ItemStack is = this.getStackInSlot( FUEL_SLOT_INDEX );
if( is != null ) if( is != null )
{ {
int newBurnTime = TileEntityFurnace.getItemBurnTime( is ); final int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
if( newBurnTime > 0 && is.stackSize > 0 ) if( newBurnTime > 0 && is.stackSize > 0 )
{ {
this.burnTime += newBurnTime; this.burnTime += newBurnTime;
@@ -252,7 +254,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
{ {
ItemStack container = null; ItemStack container = null;
if( is.getItem().hasContainerItem( is ) ) if( is.getItem() != null && is.getItem().hasContainerItem( is ) )
{ {
container = is.getItem().getContainerItem( is ); container = is.getItem().getContainerItem( is );
} }
@@ -263,6 +265,8 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
{ {
this.setInventorySlotContents( 0, is ); this.setInventorySlotContents( 0, is );
} }
this.markDirty();
} }
} }
@@ -278,10 +282,16 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
} }
} }
// state change
if( ( !this.isOn && this.burnTime > 0 ) || ( this.isOn && this.burnTime <= 0 ) ) if( ( !this.isOn && this.burnTime > 0 ) || ( this.isOn && this.burnTime <= 0 ) )
{ {
this.isOn = this.burnTime > 0; this.isOn = this.burnTime > 0;
this.markForUpdate(); this.markForUpdate();
if ( this.hasWorldObj() )
{
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
}
} }
} }
} }
@@ -30,7 +30,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -162,12 +161,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
return this.cb.getCableConnectionType( side ); return this.cb.getCableConnectionType( side );
} }
@Override
public TileEntity getTile()
{
return this;
}
@Override @Override
public void onChunkUnload() public void onChunkUnload()
{ {