Skip to content

Commit

Permalink
switched from HashSet to ArrayList.
Browse files Browse the repository at this point in the history
  • Loading branch information
PrototypeTrousers committed Apr 2, 2021
1 parent 9d734f9 commit fb9ae22
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
14 changes: 7 additions & 7 deletions src/main/java/gregtech/api/capability/INotifiableHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import gregtech.api.metatileentity.MetaTileEntity;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

/**
* For Item and Fluid handlers capable of notifying entities when
Expand All @@ -20,21 +20,21 @@ public interface INotifiableHandler {
default void notifyMetaTileEntitiesOfChange(boolean isExport) {
Iterator<MetaTileEntity> iterator = getNotifiableMetaTileEntities().iterator();
while (iterator.hasNext()) {
MetaTileEntity mte = iterator.next();
if (mte != null && mte.isValid()) {
if (isExport) mte.setOutputsDirty(true);
else mte.setInputsDirty(true);
MetaTileEntity metaTileEntity = iterator.next();
if (metaTileEntity != null && metaTileEntity.isValid()) {
if (isExport) metaTileEntity.setOutputsDirty(true);
else metaTileEntity.setInputsDirty(true);
} else {
iterator.remove();
}
}
}

/**
* returns a HashSet containing the notifiable MetaTileEntities
* returns a List containing the notifiable MetaTileEntities
* @return
*/
HashSet<MetaTileEntity> getNotifiableMetaTileEntities();
List<MetaTileEntity> getNotifiableMetaTileEntities();

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import gregtech.api.capability.INotifiableHandler;
import gregtech.api.metatileentity.MetaTileEntity;

import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;

public class NotifiableFilteredFluidHandler extends FilteredFluidHandler implements INotifiableHandler {

HashSet<MetaTileEntity> entitiesToNotify = new HashSet<>();
List<MetaTileEntity> entitiesToNotify = new ArrayList<>();
private final boolean isExport;

public NotifiableFilteredFluidHandler(int capacity, MetaTileEntity entityToNotify, boolean isExport) {
Expand All @@ -23,7 +24,7 @@ protected void onContentsChanged() {
}

@Override
public HashSet<MetaTileEntity> getNotifiableMetaTileEntities() {
public List<MetaTileEntity> getNotifiableMetaTileEntities() {
return this.entitiesToNotify;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import gregtech.api.metatileentity.MetaTileEntity;
import net.minecraftforge.fluids.FluidTank;

import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;

public class NotifiableFluidTank extends FluidTank implements INotifiableHandler {

HashSet<MetaTileEntity> entitiesToNotify = new HashSet<>();
List<MetaTileEntity> entitiesToNotify = new ArrayList<>();
private final boolean isExport;

public NotifiableFluidTank(int capacity, MetaTileEntity entityToNotify, boolean isExport) {
Expand All @@ -24,7 +25,7 @@ protected void onContentsChanged() {
}

@Override
public HashSet<MetaTileEntity> getNotifiableMetaTileEntities() {
public List<MetaTileEntity> getNotifiableMetaTileEntities() {
return this.entitiesToNotify;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;

import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;

public class NotifiableItemStackHandler extends ItemStackHandler implements IItemHandlerModifiable, INotifiableHandler {

HashSet<MetaTileEntity> entitiesToNotify = new HashSet<>();
List<MetaTileEntity> entitiesToNotify = new ArrayList<>();
private final boolean isExport;

public NotifiableItemStackHandler(int slots, MetaTileEntity entityToNotify, boolean isExport) {
Expand All @@ -25,7 +26,7 @@ public void onContentsChanged(int slot) {
}

@Override
public HashSet<MetaTileEntity> getNotifiableMetaTileEntities() {
public List<MetaTileEntity> getNotifiableMetaTileEntities() {
return this.entitiesToNotify;
}
}

0 comments on commit fb9ae22

Please sign in to comment.