Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow spray cans to color a chain of blocks when sneaking #1863

Merged
merged 2 commits into from
Apr 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

import gregtech.api.GregTech_API;
import gregtech.api.enums.ConfigCategories;
import gregtech.api.enums.Dyes;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.SoundResource;
Expand Down Expand Up @@ -75,12 +78,37 @@ public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPl
Items.feather.setDamage(aStack, Items.feather.getDamage(this.mUsed));
tUses = this.mUses;
}
if ((GT_Utility.areStacksEqual(aStack, this.mUsed, true)) && (colorize(aWorld, aX, aY, aZ, aSide))) {
int painted = 0;
int maxPainted = GregTech_API.sSpecialFile.get(ConfigCategories.general, "SprayCanChainRange", 256);
ForgeDirection lookSide;
Vec3 look = aPlayer.getLookVec();
double absX = Math.abs(look.xCoord);
double absY = Math.abs(look.yCoord);
double absZ = Math.abs(look.zCoord);
if (absX > absY && absX > absZ) {
lookSide = look.xCoord > 0 ? ForgeDirection.EAST : ForgeDirection.WEST;
} else if (absY > absX && absY > absZ) {
lookSide = look.yCoord > 0 ? ForgeDirection.UP : ForgeDirection.DOWN;
} else {
lookSide = look.zCoord > 0 ? ForgeDirection.SOUTH : ForgeDirection.NORTH;
}
while ((GT_Utility.areStacksEqual(aStack, this.mUsed, true)) && (colorize(aWorld, aX, aY, aZ, aSide))) {
GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, 1.0F, aX, aY, aZ);
if (!aPlayer.capabilities.isCreativeMode) {
tUses -= 1L;
}
rOutput = true;
painted++;
if (painted >= maxPainted && maxPainted != -1) break;
if (!aPlayer.isSneaking() || tUses <= 0) break;
switch (lookSide) {
case UP -> aY += 1;
case DOWN -> aY -= 1;
case NORTH -> aZ -= 1;
case SOUTH -> aZ += 1;
case WEST -> aX -= 1;
case EAST -> aX += 1;
}
}
tNBT.removeTag("GT.RemainingPaint");
if (tUses > 0L) {
Expand Down