Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Commit

Permalink
Opis et repare? et Balayer quelquechose avec HashedArrayList
Browse files Browse the repository at this point in the history
  • Loading branch information
robotia committed May 29, 2016
1 parent 4635dfa commit b985f79
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion patches/net/minecraft/world/World.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@
+ 1 = force tick and ignore Spigot
+ */
+ byte tickAbility = CauldronHooks.canSushchestvoTick(p_72866_1_,this);
+ if (!isForced && !canUpdate && (!org.spigotmc.ActivationRange.checkIfActive(p_72866_1_) && tickAbility != 1)) // Cauldron - ignore if forge event forced update or entity is in forced chunk
+ if (!isForced && !canUpdate && (tickAbility == -1 || (!org.spigotmc.ActivationRange.checkIfActive(p_72866_1_) && tickAbility != 1))) // Cauldron - ignore if forge event forced update or entity is in forced chunk
+ {
+ p_72866_1_.ticksExisted++;
+ p_72866_1_.inactiveTick();
Expand Down
52 changes: 28 additions & 24 deletions src/main/java/thermos/chaud/HashedArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@

import java.util.*;

public class HashedArrayList<TileEntity> implements List<TileEntity>
public class HashedArrayList<TileEntity> extends ArrayList<TileEntity>
{

private ArrayList<TileEntity> stuff = new ArrayList<TileEntity>();
private Set<TileEntity> hashed = Collections.synchronizedSet(new HashSet<TileEntity>());
public HashedArrayList()
{
super();
}

private Set<TileEntity> hashed = Collections.synchronizedSet(new LinkedHashSet<TileEntity>());

@Override
public boolean add(TileEntity arg0)
{
boolean flag = hashed.add(arg0);

if (flag)
stuff.add(arg0);
super.add(arg0);

return flag;
}
Expand All @@ -25,7 +29,7 @@ public void add(int arg0, TileEntity arg1)
boolean flag = hashed.add(arg1);

if (flag)
stuff.add(arg0, arg1);
super.add(arg0, arg1);
}

@Override
Expand All @@ -34,7 +38,7 @@ public boolean addAll(Collection arg0)
boolean flag = hashed.addAll(arg0);

if (flag)
stuff.addAll(arg0);
super.addAll(arg0);

return flag;
}
Expand All @@ -45,7 +49,7 @@ public boolean addAll(int arg0, Collection arg1)
boolean flag = hashed.addAll(arg1);

if (flag)
stuff.addAll(arg0, arg1);
super.addAll(arg0, arg1);

return flag;
}
Expand All @@ -54,7 +58,7 @@ public boolean addAll(int arg0, Collection arg1)
public void clear()
{
this.hashed.clear();
this.stuff.clear();
super.clear();
}

@Override
Expand All @@ -72,32 +76,32 @@ public boolean containsAll(Collection arg0)
@Override
public TileEntity get(int arg0)
{
return stuff.get(arg0);
return super.get(arg0);
}

@Override
public int indexOf(Object arg0)
{
return stuff.indexOf(arg0);
return super.indexOf(arg0);
}

@Override
public boolean isEmpty()
{
return stuff.isEmpty();
return super.isEmpty();
}

@Override
public Iterator<TileEntity> iterator()
{
return new HashedArrayIterator(this.stuff.iterator(), this.hashed);
return new HashedArrayIterator(super.iterator(), this.hashed);
}

@Override
public int lastIndexOf(Object arg0) {
if (this.hashed.contains(arg0))
{
return this.stuff.lastIndexOf(arg0);
return super.lastIndexOf(arg0);
}
else
{
Expand All @@ -112,20 +116,20 @@ public ListIterator listIterator() {

@Override
public ListIterator listIterator(int arg0) {
return this.stuff.listIterator(arg0);
return super.listIterator(arg0);
}

@Override
public boolean remove(Object arg0) {
boolean flag = this.hashed.remove(arg0);
if (flag)
this.stuff.remove(arg0);
super.remove(arg0);
return flag;
}

@Override
public TileEntity remove(int arg0) {
TileEntity te = this.stuff.remove(arg0);
TileEntity te = super.remove(arg0);

if (te != null)
hashed.remove(te);
Expand All @@ -139,8 +143,8 @@ public boolean removeAll(Collection arg0) {

if (flag)
{
this.stuff = new ArrayList<TileEntity>((int)(hashed.size()*1.5)+1);
for(TileEntity te : hashed) this.stuff.add(te);
super.clear();
super.addAll(this.hashed);
}

return flag;
Expand All @@ -151,15 +155,15 @@ public boolean retainAll(Collection arg0) {
boolean flag = this.hashed.retainAll(arg0);

if (flag)
this.stuff = new ArrayList<TileEntity>(hashed);
super.retainAll(arg0);

return flag;
}

@Override
public TileEntity set(int arg0, TileEntity arg1)
{
TileEntity te = this.stuff.set(arg0, arg1);
TileEntity te = super.set(arg0, arg1);

if (te != null)
this.hashed.remove(arg1);
Expand All @@ -169,25 +173,25 @@ public TileEntity set(int arg0, TileEntity arg1)

@Override
public int size() {
return this.stuff.size();
return super.size();
}

@Override
public List<TileEntity> subList(int arg0, int arg1)
{
return this.stuff.subList(arg0, arg1);
return super.subList(arg0, arg1);
}

@Override
public Object[] toArray()
{
return this.stuff.toArray();
return super.toArray();
}

@Override
public Object[] toArray(Object[] arg0)
{
return this.stuff.toArray(arg0);
return super.toArray(arg0);
}

class HashedArrayIterator<TileEntity> implements Iterator<TileEntity>
Expand Down

0 comments on commit b985f79

Please sign in to comment.