mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-23 13:29:40 +00:00
Generalized some of the multiblock code into a stricter format
This commit is contained in:
1 parent
8f6cf7e1c9
commit
c97f617692
4 files changed
+91
-57
No files matched your search
@@ -0,0 +1,63 @@
|
||||
package mekanism.common.multiblock;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.tank.SynchronizedTankData;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class SynchronizedData<T>
|
||||
{
|
||||
public Set<Coord4D> locations = new HashSet<Coord4D>();
|
||||
|
||||
public int volLength;
|
||||
|
||||
public int volWidth;
|
||||
|
||||
public int volHeight;
|
||||
|
||||
public int volume;
|
||||
|
||||
public int inventoryID;
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31 * locations.hashCode();
|
||||
code = 31 * volLength;
|
||||
code = 31 * volWidth;
|
||||
code = 31 * volHeight;
|
||||
code = 31 * volume;
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(obj == null || obj.getClass() != getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SynchronizedData<T> data = (SynchronizedData<T>)obj;
|
||||
|
||||
if(!data.locations.equals(locations))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(data.volLength != volLength || data.volWidth != volWidth || data.volHeight != volHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(data.volume != volume)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user