Skip to content

Commit fab816a

Browse files
committed
sprayless
1 parent 3ac032c commit fab816a

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

src/main/java/gregtech/api/pipenet/block/BlockPipe.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,16 +656,19 @@ private List<IndexedCuboid6> getCollisionBox(IBlockAccess world, BlockPos pos, @
656656

657657
public boolean hasPipeCollisionChangingItem(IBlockAccess world, BlockPos pos, Entity entity) {
658658
if (entity instanceof EntityPlayer) {
659-
return hasPipeCollisionChangingItem(world, pos, ((EntityPlayer) entity).getHeldItem(EnumHand.MAIN_HAND), entity) ||
660-
hasPipeCollisionChangingItem(world, pos, ((EntityPlayer) entity).getHeldItem(EnumHand.OFF_HAND), entity) ||
659+
return hasPipeCollisionChangingItem(world, pos, ((EntityPlayer) entity).getHeldItem(EnumHand.MAIN_HAND),
660+
entity) ||
661+
hasPipeCollisionChangingItem(world, pos, ((EntityPlayer) entity).getHeldItem(EnumHand.OFF_HAND),
662+
entity) ||
661663
entity.isSneaking() && isHoldingPipe((EntityPlayer) entity);
662664
}
663665
return false;
664666
}
665667

666668
public abstract boolean isHoldingPipe(EntityPlayer player);
667669

668-
public boolean hasPipeCollisionChangingItem(IBlockAccess world, BlockPos pos, ItemStack stack, @Nullable Entity entity) {
670+
public boolean hasPipeCollisionChangingItem(IBlockAccess world, BlockPos pos, ItemStack stack,
671+
@Nullable Entity entity) {
669672
if (isPipeTool(stack)) return true;
670673

671674
if (entity != null && entity.isSneaking() && entity instanceof EntityPlayer player &&

src/main/java/gregtech/api/util/GTUtility.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import gregtech.api.recipes.RecipeMap;
1919
import gregtech.api.unification.OreDictUnifier;
2020
import gregtech.api.unification.ore.OrePrefix;
21-
2221
import gregtech.common.items.behaviors.ColorSprayBehaviour;
2322

2423
import net.minecraft.block.BlockRedstoneWire;
@@ -569,14 +568,15 @@ public static boolean isCoverBehaviorItem(ItemStack itemStack, @Nullable Boolean
569568
return false;
570569
}
571570

572-
/** Checks if an item is a spray can for rendering the machine grid
571+
/**
572+
* Checks if an item is a spray can for rendering the machine grid
573573
*
574574
* @param itemStack itemStack to check
575575
* @return If the itemStack has the behaviour of a spray can
576576
*/
577577
public static boolean isSprayCan(ItemStack itemStack) {
578578
Item item = itemStack.getItem();
579-
if (item instanceof MetaItem<?> metaItem) {
579+
if (item instanceof MetaItem<?>metaItem) {
580580
MetaItem<?>.MetaValueItem valueItem = metaItem.getItem(itemStack);
581581
if (valueItem != null) {
582582
for (IItemBehaviour behaviour : valueItem.getBehaviours()) {
@@ -587,7 +587,6 @@ public static boolean isSprayCan(ItemStack itemStack) {
587587
return false;
588588
}
589589

590-
591590
/**
592591
* Default function for tank sizes, takes a tier input and returns the corresponding size
593592
*/

src/main/java/gregtech/common/ToolEventHandlers.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ private static boolean shouldRenderGridOverlays(@NotNull IBlockState state, @Nul
305305
ItemStack mainHand, ItemStack offHand, boolean isSneaking) {
306306
if (state.getBlock() instanceof BlockPipe<?, ?, ?>pipe) {
307307
if (isSneaking &&
308-
(mainHand.isEmpty() || mainHand.getItem().getClass() == Item.getItemFromBlock(pipe).getClass() || GTUtility.isSprayCan(mainHand) || GTUtility.isSprayCan(offHand))) {
308+
(mainHand.isEmpty() || mainHand.getItem().getClass() == Item.getItemFromBlock(pipe).getClass() ||
309+
GTUtility.isSprayCan(mainHand) || GTUtility.isSprayCan(offHand))) {
309310
return true;
310311
} else {
311312
Set<String> mainToolClasses = mainHand.getItem().getToolClasses(mainHand);

src/main/java/gregtech/common/items/behaviors/ColorSprayBehaviour.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package gregtech.common.items.behaviors;
22

3-
import codechicken.lib.raytracer.RayTracer;
4-
53
import gregtech.api.GTValues;
64
import gregtech.api.cover.CoverRayTracer;
75
import gregtech.api.items.metaitem.stats.IItemDurabilityManager;
@@ -31,6 +29,7 @@
3129

3230
import appeng.api.util.AEColor;
3331
import appeng.tile.networking.TileCableBus;
32+
import codechicken.lib.raytracer.RayTracer;
3433
import org.apache.commons.lang3.tuple.Pair;
3534
import org.jetbrains.annotations.Nullable;
3635

@@ -57,7 +56,7 @@ public ColorSprayBehaviour(ItemStack empty, int totalUses, int color) {
5756
@Override
5857
public ActionResult<ItemStack> onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand,
5958
EnumFacing facing, float hitX, float hitY, float hitZ) {
60-
ItemStack stack = player.getHeldItem(hand);
59+
ItemStack stack = player.getHeldItem(hand);
6160
if (!player.canPlayerEdit(pos, facing, stack)) {
6261
return ActionResult.newResult(EnumActionResult.FAIL, player.getHeldItem(hand));
6362
}
@@ -76,7 +75,8 @@ private boolean tryPaintBlock(EntityPlayer player, World world, BlockPos pos, En
7675
if (color == null) {
7776
return tryStripBlockColor(player, world, pos, block, side, hand);
7877
}
79-
return tryPaintSpecialBlock(player, world, pos, block, hand) || block.recolorBlock(world, pos, side, this.color);
78+
return tryPaintSpecialBlock(player, world, pos, block, hand) ||
79+
block.recolorBlock(world, pos, side, this.color);
8080
}
8181

8282
private boolean tryPaintSpecialBlock(EntityPlayer player, World world, BlockPos pos, Block block, EnumHand hand) {
@@ -99,7 +99,7 @@ private boolean tryPaintSpecialBlock(EntityPlayer player, World world, BlockPos
9999
return true;
100100
}
101101
TileEntity te = world.getTileEntity(pos);
102-
if (player.isSneaking() && te instanceof IPipeTile<?,?> mainPipe) {
102+
if (player.isSneaking() && te instanceof IPipeTile<?, ?>mainPipe) {
103103
RayTraceResult hitResult = RayTracer.retraceBlock(world, player, pos);
104104
if (hitResult != null) {
105105
EnumFacing facing = CoverRayTracer.determineGridSideHit(hitResult);
@@ -131,12 +131,13 @@ private boolean tryPaintSpecialBlock(EntityPlayer player, World world, BlockPos
131131

132132
// note: automatically uses durability from recolouring pipes, apart from the last use, as this allows for proper
133133
// animation of the item's use
134-
private boolean traversePipes(EntityPlayer player, World world, EnumHand hand, BlockPos startPos, EnumFacing facing) {
134+
private boolean traversePipes(EntityPlayer player, World world, EnumHand hand, BlockPos startPos,
135+
EnumFacing facing) {
135136
startPos = startPos.offset(facing);
136137
TileEntity connectedTe = world.getTileEntity(startPos);
137138
int count = 1;
138139
boolean painted = false;
139-
while (connectedTe instanceof IPipeTile<?,?> connectedPipe && count < MAX_PIPE_TRAVERSAL_LENGTH) {
140+
while (connectedTe instanceof IPipeTile<?, ?>connectedPipe && count < MAX_PIPE_TRAVERSAL_LENGTH) {
140141
if (connectedPipe.getPaintingColor() != (this.color == null ? -1 : this.color.colorValue)) {
141142
connectedPipe.setPaintingColor(this.color == null ? -1 : this.color.colorValue);
142143
connectedPipe.scheduleRenderUpdate();
@@ -154,7 +155,7 @@ private boolean traversePipes(EntityPlayer player, World world, EnumHand hand, B
154155
if (connectedPipe.getNumConnections() == 2) {
155156
int connections = connectedPipe.getConnections();
156157
connections &= ~(1 << facing.getOpposite().getIndex());
157-
for (EnumFacing other: EnumFacing.VALUES) {
158+
for (EnumFacing other : EnumFacing.VALUES) {
158159
if ((connections & (1 << other.getIndex())) != 0) {
159160
facing = other;
160161
startPos = startPos.offset(facing);
@@ -172,7 +173,7 @@ private boolean traversePipes(EntityPlayer player, World world, EnumHand hand, B
172173

173174
@SuppressWarnings("unchecked, rawtypes")
174175
private boolean tryStripBlockColor(EntityPlayer player, World world, BlockPos pos, Block block,
175-
EnumFacing side, EnumHand hand) {
176+
EnumFacing side, EnumHand hand) {
176177
// MC special cases
177178
if (block == Blocks.STAINED_GLASS) {
178179
world.setBlockState(pos, Blocks.GLASS.getDefaultState());
@@ -200,7 +201,7 @@ private boolean tryStripBlockColor(EntityPlayer player, World world, BlockPos po
200201
}
201202

202203
// TileEntityPipeBase special case
203-
if (te instanceof IPipeTile<?, ?> pipe) {
204+
if (te instanceof IPipeTile<?, ?>pipe) {
204205
if (player.isSneaking()) {
205206
RayTraceResult hitResult = RayTracer.retraceBlock(world, player, pos);
206207
if (hitResult != null) {

0 commit comments

Comments
 (0)