82 lines
3.0 KiB
Diff
82 lines
3.0 KiB
Diff
--- a/net/minecraft/tileentity/TileEntity.java
|
|
+++ b/net/minecraft/tileentity/TileEntity.java
|
|
@@ -16,7 +16,7 @@
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
-public abstract class TileEntity {
|
|
+public abstract class TileEntity extends net.minecraftforge.common.capabilities.CapabilityProvider<TileEntity> implements net.minecraftforge.common.extensions.IForgeTileEntity {
|
|
private static final Logger field_145852_a = LogManager.getLogger();
|
|
private final TileEntityType<?> field_200663_e;
|
|
@Nullable
|
|
@@ -26,9 +26,12 @@
|
|
@Nullable
|
|
private BlockState field_195045_e;
|
|
private boolean field_222816_g;
|
|
+ private CompoundNBT customTileData;
|
|
|
|
public TileEntity(TileEntityType<?> p_i48289_1_) {
|
|
+ super(TileEntity.class);
|
|
this.field_200663_e = p_i48289_1_;
|
|
+ this.gatherCapabilities();
|
|
}
|
|
|
|
@Nullable
|
|
@@ -47,6 +50,8 @@
|
|
|
|
public void func_230337_a_(BlockState p_230337_1_, CompoundNBT p_230337_2_) {
|
|
this.field_174879_c = new BlockPos(p_230337_2_.func_74762_e("x"), p_230337_2_.func_74762_e("y"), p_230337_2_.func_74762_e("z"));
|
|
+ if (p_230337_2_.func_74764_b("ForgeData")) this.customTileData = p_230337_2_.func_74775_l("ForgeData");
|
|
+ if (getCapabilities() != null && p_230337_2_.func_74764_b("ForgeCaps")) deserializeCaps(p_230337_2_.func_74775_l("ForgeCaps"));
|
|
}
|
|
|
|
public CompoundNBT func_189515_b(CompoundNBT p_189515_1_) {
|
|
@@ -62,6 +67,8 @@
|
|
p_189516_1_.func_74768_a("x", this.field_174879_c.func_177958_n());
|
|
p_189516_1_.func_74768_a("y", this.field_174879_c.func_177956_o());
|
|
p_189516_1_.func_74768_a("z", this.field_174879_c.func_177952_p());
|
|
+ if (this.customTileData != null) p_189516_1_.func_218657_a("ForgeData", this.customTileData);
|
|
+ if (getCapabilities() != null) p_189516_1_.func_218657_a("ForgeCaps", serializeCaps());
|
|
return p_189516_1_;
|
|
}
|
|
}
|
|
@@ -94,7 +101,7 @@
|
|
if (this.field_145850_b != null) {
|
|
this.field_195045_e = this.field_145850_b.func_180495_p(this.field_174879_c);
|
|
this.field_145850_b.func_175646_b(this.field_174879_c, this);
|
|
- if (!this.field_195045_e.func_196958_f()) {
|
|
+ if (!this.field_195045_e.isAir(this.field_145850_b, this.field_174879_c)) {
|
|
this.field_145850_b.func_175666_e(this.field_174879_c, this.field_195045_e.func_177230_c());
|
|
}
|
|
}
|
|
@@ -133,8 +140,15 @@
|
|
|
|
public void func_145843_s() {
|
|
this.field_145846_f = true;
|
|
+ this.invalidateCaps();
|
|
+ requestModelDataUpdate();
|
|
}
|
|
|
|
+ @Override
|
|
+ public void onChunkUnloaded() {
|
|
+ this.invalidateCaps();
|
|
+ }
|
|
+
|
|
public void func_145829_t() {
|
|
this.field_145846_f = false;
|
|
}
|
|
@@ -175,6 +189,13 @@
|
|
return this.field_200663_e;
|
|
}
|
|
|
|
+ @Override
|
|
+ public CompoundNBT getTileData() {
|
|
+ if (this.customTileData == null)
|
|
+ this.customTileData = new CompoundNBT();
|
|
+ return this.customTileData;
|
|
+ }
|
|
+
|
|
public void func_222814_r() {
|
|
if (!this.field_222816_g) {
|
|
this.field_222816_g = true;
|