Multiple blocked items for drills + Blocked items for beam drills (#8527)
* Multiple blocked items for drills Works similarly to output item with GenericCrafters * blocked items for beam drills
This commit is contained in:
@@ -45,6 +45,10 @@ public class BeamDrill extends Block{
|
||||
|
||||
/** Multipliers of drill speed for each item. Defaults to 1. */
|
||||
public ObjectFloatMap<Item> drillMultipliers = new ObjectFloatMap<>();
|
||||
/** Special exemption item that this drill can't mine. */
|
||||
public @Nullable Item blockedItem;
|
||||
/** Special exemption items that this drill can't mine. */
|
||||
public @Nullable Seq<Item> blockedItems;
|
||||
|
||||
public Color sparkColor = Color.valueOf("fd9e81"), glowColor = Color.white;
|
||||
public float glowIntensity = 0.2f, pulseIntensity = 0.07f;
|
||||
@@ -76,6 +80,9 @@ public class BeamDrill extends Block{
|
||||
public void init(){
|
||||
updateClipRadius((range + 2) * tilesize);
|
||||
super.init();
|
||||
if(blockedItems == null && blockedItem != null){
|
||||
blockedItems = Seq.with(blockedItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +118,10 @@ public class BeamDrill extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(Stat.drillTier, StatValues.drillables(drillTime, 0f, size, drillMultipliers, b -> (b instanceof Floor f && f.wallOre && f.itemDrop != null && f.itemDrop.hardness <= tier) || (b instanceof StaticWall w && w.itemDrop != null && w.itemDrop.hardness <= tier)));
|
||||
stats.add(Stat.drillTier, StatValues.drillables(drillTime, 0f, size, drillMultipliers, b ->
|
||||
(b instanceof Floor f && f.wallOre && f.itemDrop != null && f.itemDrop.hardness <= tier && (blockedItems == null || !blockedItems.contains(f.itemDrop))) ||
|
||||
(b instanceof StaticWall w && w.itemDrop != null && w.itemDrop.hardness <= tier && (blockedItems == null || !blockedItems.contains(w.itemDrop)))
|
||||
));
|
||||
|
||||
stats.add(Stat.drillSpeed, 60f / drillTime * size, StatUnit.itemsSecond);
|
||||
|
||||
@@ -142,7 +152,7 @@ public class BeamDrill extends Block{
|
||||
if(other != null && other.solid()){
|
||||
Item drop = other.wallDrop();
|
||||
if(drop != null){
|
||||
if(drop.hardness <= tier){
|
||||
if(drop.hardness <= tier && (blockedItems == null || !blockedItems.contains(drop))){
|
||||
found = drop;
|
||||
count++;
|
||||
}else{
|
||||
@@ -193,7 +203,7 @@ public class BeamDrill extends Block{
|
||||
Tile other = world.tile(Tmp.p1.x + Geometry.d4x(rotation)*j, Tmp.p1.y + Geometry.d4y(rotation)*j);
|
||||
if(other != null && other.solid()){
|
||||
Item drop = other.wallDrop();
|
||||
if(drop != null && drop.hardness <= tier){
|
||||
if(drop != null && drop.hardness <= tier && (blockedItems == null || !blockedItems.contains(drop))){
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@@ -379,7 +389,7 @@ public class BeamDrill extends Block{
|
||||
if(other != null){
|
||||
if(other.solid()){
|
||||
Item drop = other.wallDrop();
|
||||
if(drop != null && drop.hardness <= tier){
|
||||
if(drop != null && drop.hardness <= tier && (blockedItems == null || !blockedItems.contains(drop))){
|
||||
facingAmount ++;
|
||||
if(lastItem != drop && lastItem != null){
|
||||
multiple = true;
|
||||
|
||||
@@ -40,6 +40,8 @@ public class Drill extends Block{
|
||||
public float warmupSpeed = 0.015f;
|
||||
/** Special exemption item that this drill can't mine. */
|
||||
public @Nullable Item blockedItem;
|
||||
/** Special exemption items that this drill can't mine. */
|
||||
public @Nullable Seq<Item> blockedItems;
|
||||
|
||||
//return variables for countOre
|
||||
protected @Nullable Item returnItem;
|
||||
@@ -89,6 +91,9 @@ public class Drill extends Block{
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
if(blockedItems == null && blockedItem != null){
|
||||
blockedItems = Seq.with(blockedItem);
|
||||
}
|
||||
if(drillEffectRnd < 0) drillEffectRnd = size;
|
||||
}
|
||||
|
||||
@@ -155,7 +160,7 @@ public class Drill extends Block{
|
||||
Draw.color();
|
||||
}
|
||||
}else{
|
||||
Tile to = tile.getLinkedTilesAs(this, tempTiles).find(t -> t.drop() != null && (t.drop().hardness > tier || t.drop() == blockedItem));
|
||||
Tile to = tile.getLinkedTilesAs(this, tempTiles).find(t -> t.drop() != null && (t.drop().hardness > tier || (blockedItems != null && blockedItems.contains(t.drop()))));
|
||||
Item item = to == null ? null : to.drop();
|
||||
if(item != null){
|
||||
drawPlaceText(Core.bundle.get("bar.drilltierreq"), x, y, valid);
|
||||
@@ -172,7 +177,7 @@ public class Drill extends Block{
|
||||
super.setStats();
|
||||
|
||||
stats.add(Stat.drillTier, StatValues.drillables(drillTime, hardnessDrillMultiplier, size * size, drillMultipliers, b -> b instanceof Floor f && !f.wallOre && f.itemDrop != null &&
|
||||
f.itemDrop.hardness <= tier && f.itemDrop != blockedItem && (indexer.isBlockPresent(f) || state.isMenu())));
|
||||
f.itemDrop.hardness <= tier && (blockedItems == null || !blockedItems.contains(f.itemDrop)) && (indexer.isBlockPresent(f) || state.isMenu())));
|
||||
|
||||
stats.add(Stat.drillSpeed, 60f / drillTime * size * size, StatUnit.itemsSecond);
|
||||
|
||||
@@ -227,7 +232,7 @@ public class Drill extends Block{
|
||||
public boolean canMine(Tile tile){
|
||||
if(tile == null || tile.block().isStatic()) return false;
|
||||
Item drops = tile.drop();
|
||||
return drops != null && drops.hardness <= tier && drops != blockedItem;
|
||||
return drops != null && drops.hardness <= tier && (blockedItems == null || !blockedItems.contains(drops));
|
||||
}
|
||||
|
||||
public class DrillBuild extends Building{
|
||||
|
||||
Reference in New Issue
Block a user