Created build.gradle
Restructured folder structure for ForgeGradle Signed-off-by: deathrat <deathrat43@gmail.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package StevenDimDoors.mod_pocketDim.watcher;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
|
||||
public class ClientDimData
|
||||
{
|
||||
//We'll use public fields since this is just a data container and it's immutable
|
||||
public final int ID;
|
||||
public final int RootID;
|
||||
|
||||
public ClientDimData(int id, int rootID)
|
||||
{
|
||||
ID = id;
|
||||
RootID = rootID;
|
||||
}
|
||||
|
||||
public ClientDimData(NewDimData dimension)
|
||||
{
|
||||
ID = dimension.id();
|
||||
RootID = dimension.root().id();
|
||||
}
|
||||
|
||||
public void write(DataOutputStream output) throws IOException
|
||||
{
|
||||
output.writeInt(ID);
|
||||
output.writeInt(RootID);
|
||||
}
|
||||
|
||||
public static ClientDimData read(DataInputStream input) throws IOException
|
||||
{
|
||||
int id = input.readInt();
|
||||
int rootId = input.readInt();
|
||||
return new ClientDimData(id, rootId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package StevenDimDoors.mod_pocketDim.watcher;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class ClientLinkData
|
||||
{
|
||||
public Point4D point;
|
||||
public int orientation;
|
||||
|
||||
public ClientLinkData(DimLink link)
|
||||
{
|
||||
this.point= link.source();
|
||||
this.orientation=link.orientation();
|
||||
}
|
||||
|
||||
public ClientLinkData(Point4D point, int orientation)
|
||||
{
|
||||
this.point = point;
|
||||
this.orientation=orientation;
|
||||
}
|
||||
|
||||
public void write(DataOutputStream output) throws IOException
|
||||
{
|
||||
Point4D.write(point, output);
|
||||
output.writeInt(orientation);
|
||||
}
|
||||
|
||||
public static ClientLinkData read(DataInputStream input) throws IOException
|
||||
{
|
||||
Point4D point = Point4D.read(input);
|
||||
int orientation = input.readInt();
|
||||
return new ClientLinkData(point, orientation);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package StevenDimDoors.mod_pocketDim.watcher;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public interface IUpdateSource
|
||||
{
|
||||
public void registerWatchers(IUpdateWatcher<ClientDimData> dimWatcher, IUpdateWatcher<ClientLinkData> linkWatcher);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package StevenDimDoors.mod_pocketDim.watcher;
|
||||
|
||||
public interface IUpdateWatcher<T>
|
||||
{
|
||||
public void onCreated(T message);
|
||||
public void onDeleted(T message);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package StevenDimDoors.mod_pocketDim.watcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UpdateWatcherProxy<T> implements IUpdateWatcher<T>
|
||||
{
|
||||
private List<IUpdateWatcher<T>> watchers;
|
||||
|
||||
public UpdateWatcherProxy()
|
||||
{
|
||||
watchers = new ArrayList<IUpdateWatcher<T>>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(T message)
|
||||
{
|
||||
for (IUpdateWatcher<T> receiver : watchers)
|
||||
{
|
||||
receiver.onCreated(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(T message)
|
||||
{
|
||||
for (IUpdateWatcher<T> receiver : watchers)
|
||||
{
|
||||
receiver.onDeleted(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerReceiver(IUpdateWatcher<T> receiver)
|
||||
{
|
||||
watchers.add(receiver);
|
||||
}
|
||||
|
||||
public boolean unregisterReceiver(IUpdateWatcher<T> receiver)
|
||||
{
|
||||
return watchers.remove(receiver);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user