diff --git a/src/main/java/appeng/me/Grid.java b/src/main/java/appeng/me/Grid.java index 7d23a68ca95..bee3ddf7f13 100644 --- a/src/main/java/appeng/me/Grid.java +++ b/src/main/java/appeng/me/Grid.java @@ -36,7 +36,7 @@ public class Grid implements IGrid { private final NetworkEventBus eventBus = new NetworkEventBus(); private final Map, MachineSet> machines = new HashMap<>(); - private final Map, GridCacheWrapper> caches = new HashMap<>(); + private final Map, IGridCache> caches = new HashMap<>(); private GridNode pivot; private int priority; // how import is this network? private GridStorage myStorage; @@ -56,7 +56,7 @@ public Grid(final GridNode center) { final Class valueClass = value.getClass(); this.eventBus.readClass(key, valueClass); - this.caches.put(key, new GridCacheWrapper(value)); + this.caches.put(key, value); } this.postEvent(new MENetworkPostCacheConstruction()); @@ -73,7 +73,7 @@ IGridStorage getMyStorage() { return this.myStorage; } - Map, GridCacheWrapper> getCaches() { + Map, IGridCache> getCaches() { return this.caches; } @@ -179,7 +179,7 @@ void add(final GridNode gridNode) { @Override @SuppressWarnings("unchecked") public C getCache(final Class iface) { - return (C) this.caches.get(iface).getCache(); + return (C) this.caches.get(iface); } @Override diff --git a/src/main/java/appeng/me/GridCacheWrapper.java b/src/main/java/appeng/me/GridCacheWrapper.java deleted file mode 100644 index 929d003381c..00000000000 --- a/src/main/java/appeng/me/GridCacheWrapper.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of Applied Energistics 2. Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. Applied - * Energistics 2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any - * later version. Applied Energistics 2 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 Lesser General - * Public License for more details. You should have received a copy of the GNU Lesser General Public License along with - * Applied Energistics 2. If not, see . - */ - -package appeng.me; - -import appeng.api.networking.IGridCache; -import appeng.api.networking.IGridHost; -import appeng.api.networking.IGridNode; -import appeng.api.networking.IGridStorage; - -public class GridCacheWrapper implements IGridCache { - - private final IGridCache myCache; - private final String name; - - public GridCacheWrapper(final IGridCache gc) { - this.myCache = gc; - this.name = this.getCache().getClass().getName(); - } - - @Override - public void onUpdateTick() { - this.getCache().onUpdateTick(); - } - - @Override - public void removeNode(final IGridNode gridNode, final IGridHost machine) { - this.getCache().removeNode(gridNode, machine); - } - - @Override - public void addNode(final IGridNode gridNode, final IGridHost machine) { - this.getCache().addNode(gridNode, machine); - } - - @Override - public void onSplit(final IGridStorage storageB) { - this.getCache().onSplit(storageB); - } - - @Override - public void onJoin(final IGridStorage storageB) { - this.getCache().onJoin(storageB); - } - - @Override - public void populateGridStorage(final IGridStorage storage) { - this.getCache().populateGridStorage(storage); - } - - public String getName() { - return this.name; - } - - IGridCache getCache() { - return this.myCache; - } -} diff --git a/src/main/java/appeng/me/NetworkEventBus.java b/src/main/java/appeng/me/NetworkEventBus.java index e5ed4b00c51..60fbd75e8db 100644 --- a/src/main/java/appeng/me/NetworkEventBus.java +++ b/src/main/java/appeng/me/NetworkEventBus.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.Map.Entry; +import appeng.api.networking.IGridCache; import appeng.api.networking.IGridNode; import appeng.api.networking.events.MENetworkEvent; import appeng.api.networking.events.MENetworkEventSubscribe; @@ -79,10 +80,10 @@ MENetworkEvent postEvent(final Grid g, final MENetworkEvent e) { if (subscribers != null) { for (final Entry subscriber : subscribers.entrySet()) { final MENetworkEventInfo target = subscriber.getValue(); - final GridCacheWrapper cache = g.getCaches().get(subscriber.getKey()); + final IGridCache cache = g.getCaches().get(subscriber.getKey()); if (cache != null) { x++; - target.invoke(cache.getCache(), e); + target.invoke(cache, e); } for (final IGridNode obj : g.getMachines(subscriber.getKey())) {