Fixed Ritual Tinkerer & added range reset (#1636)

* Add getMinimumOffset() and getMaximumOffset to AreaDescriptor
Add the ability to reset BlockRanges to the Ritual Tinkerer

* Added copy-constructors and functions to AreaDescriptor
Added the ability to reset BlockRanges to the Ritual Tinkerer
- Mode: Define Area, with BloodOrb in offhand & sneaking, right click on MRS

Changed "addBlockRange" and "addBlockRanges" to use .putIfAbsent
Added "setBlockRange" and "setBlockRanges" to IMasterRitualStone
- reference implementation in TileMasterRitualStone is identical to old "addBlockRange" and "addBlockRanges"

Fixed range setting for good.

Tested behavior with RitualWater.

* Minor cleanup

* Remove TODO
This commit is contained in:
Tobias 2019-09-05 03:58:45 +02:00 committed by Nick Ignoffo
parent a23cd35556
commit 1155be6d6b
4 changed files with 75 additions and 9 deletions

View file

@ -32,6 +32,7 @@ import javax.annotation.Nullable;
import java.util.*;
public class TileMasterRitualStone extends TileTicking implements IMasterRitualStone {
protected final Map<String, AreaDescriptor> modableRangeMap = new HashMap<>();
private UUID owner;
private SoulNetwork cachedNetwork;
private boolean active;
@ -42,7 +43,6 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS
private EnumFacing direction = EnumFacing.NORTH;
private boolean inverted;
private List<EnumDemonWillType> currentActiveWillConfig = new ArrayList<>();
protected final Map<String, AreaDescriptor> modableRangeMap = new HashMap<>();
@Override
public void onUpdate() {
@ -425,13 +425,27 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS
return null;
}
@Override
public void addBlockRange(String range, AreaDescriptor defaultRange) {
modableRangeMap.put(range, defaultRange);
modableRangeMap.putIfAbsent(range, defaultRange.copy());
}
@Override
public void addBlockRanges(Map<String, AreaDescriptor> blockRanges) {
for (Map.Entry<String, AreaDescriptor> entry : blockRanges.entrySet()) {
modableRangeMap.put(entry.getKey(), entry.getValue());
modableRangeMap.putIfAbsent(entry.getKey(), entry.getValue().copy());
}
}
@Override
public void setBlockRange(String range, AreaDescriptor defaultRange) {
modableRangeMap.put(range, defaultRange.copy());
}
@Override
public void setBlockRanges(Map<String, AreaDescriptor> blockRanges) {
for (Map.Entry<String, AreaDescriptor> entry : blockRanges.entrySet()) {
modableRangeMap.put(entry.getKey(), entry.getValue().copy());
}
}