Skip to content

Commit 491bca8

Browse files
committed
Merge branch 'master-MC1.12' into memory_zero_Array
2 parents f25638a + 42435ea commit 491bca8

File tree

21 files changed

+36
-34
lines changed

21 files changed

+36
-34
lines changed

botany-api/src/main/java/binnie/botany/api/genetics/EnumFlowerColor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
import binnie.botany.api.BotanyAPI;
66
import binnie.botany.api.IBotanyColored;
7-
import net.minecraft.util.IStringSerializable;
87

98
import net.minecraft.util.text.TextFormatting;
10-
import net.minecraft.util.text.translation.I18n;
119

1210
public enum EnumFlowerColor implements IBotanyColored {
1311
Aquamarine("aquamarine", new Color(8388564)),

botany/src/main/java/binnie/botany/blocks/BlockFlower.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity
155155
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
156156
TileEntity flower = world.getTileEntity(pos);
157157
if (world.isRemote) {
158-
if (flower != null && flower instanceof TileEntityFlower) {
158+
if (flower instanceof TileEntityFlower) {
159159
IFlower f = flowerRoot.getMember(stack);
160160
if (f != null) {
161161
((TileEntityFlower) flower).setRender(new FlowerRenderInfo(f, (TileEntityFlower) flower));
@@ -165,7 +165,7 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity
165165
}
166166

167167
TileEntity below = world.getTileEntity(pos.down());
168-
if (flower != null && flower instanceof TileEntityFlower) {
168+
if (flower instanceof TileEntityFlower) {
169169
if (below instanceof TileEntityFlower) {
170170
((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
171171
} else {

botany/src/main/java/binnie/botany/genetics/FlowerRoot.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public boolean plant(World world, BlockPos pos, IFlower flower, GameProfile owne
300300

301301
TileEntity tile = world.getTileEntity(pos);
302302
TileEntity below = world.getTileEntity(pos.down());
303-
if (tile != null && tile instanceof TileEntityFlower) {
303+
if (tile instanceof TileEntityFlower) {
304304
TileEntityFlower tileFlower = (TileEntityFlower) tile;
305305
if (below instanceof TileEntityFlower) {
306306
tileFlower.setSection(((TileEntityFlower) below).getSection());
@@ -320,7 +320,7 @@ public void tryGrowSection(World world, BlockPos pos) {
320320
}
321321

322322
TileEntity tileFlower = world.getTileEntity(pos);
323-
if (tileFlower == null || !(tileFlower instanceof TileEntityFlower)) {
323+
if (!(tileFlower instanceof TileEntityFlower)) {
324324
return;
325325
}
326326

@@ -335,7 +335,7 @@ public void tryGrowSection(World world, BlockPos pos) {
335335
if (blockAbove.getBlock().isReplaceable(world, up)) {
336336
world.setBlockState(up, ModuleFlowers.flower.getDefaultState());
337337
TileEntity flowerAbove = world.getTileEntity(up);
338-
if (flowerAbove != null && flowerAbove instanceof TileEntityFlower) {
338+
if (flowerAbove instanceof TileEntityFlower) {
339339
((TileEntityFlower) flowerAbove).setSection(section + 1);
340340
}
341341
}

botany/src/main/java/binnie/botany/genetics/gui/analyst/AnalystPageAppearance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private static class FlowerIconDisplay extends ControlIconDisplay {
5959
private final IFlowerType type;
6060

6161
public FlowerIconDisplay(AnalystPageAppearance analystPageAppearance, int width, int y, int sections, IFlower flower, IFlowerType type) {
62-
super(analystPageAppearance, (analystPageAppearance.getWidth() - width) / 2, y - ((sections == 1) ? 0 : 0));
62+
super(analystPageAppearance, (analystPageAppearance.getWidth() - width) / 2, y );
6363
this.width = width;
6464
this.sections = sections;
6565
this.flower = flower;

botany/src/main/java/binnie/botany/tile/TileEntityFlower.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public SPacketUpdateTileEntity getUpdatePacket() {
356356
public void updateRender(boolean update) {
357357
if (update && getFlower() != null && getFlower().getGenome() != null) {
358358
FlowerRenderInfo newInfo = new FlowerRenderInfo(getFlower(), this);
359-
if (renderInfo == null || !newInfo.equals(renderInfo)) {
359+
if (!newInfo.equals(renderInfo)) {
360360
setRender(newInfo);
361361
}
362362
}

core-api/src/main/java/binnie/core/api/gui/ITopLevelWidget.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import javax.annotation.Nullable;
44

5-
import binnie.core.api.gui.IPoint;
6-
import binnie.core.api.gui.IWidget;
7-
85
public interface ITopLevelWidget extends IWidget {
96
IPoint getAbsoluteMousePosition();
107

core/src/main/java/binnie/core/Binnie.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6-
import binnie.core.ManagerBase;
76
import binnie.core.genetics.ManagerGenetics;
87
import binnie.core.liquid.ManagerLiquid;
98
import binnie.core.machines.ManagerMachine;

core/src/main/java/binnie/core/genetics/AlleleHelper.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package binnie.core.genetics;
22

33
import java.util.Locale;
4+
import java.util.regex.Pattern;
45

6+
import binnie.core.util.EmptyHelper;
57
import org.apache.commons.lang3.text.WordUtils;
68

79
import forestry.api.core.EnumHumidity;
@@ -13,6 +15,8 @@
1315

1416
import binnie.core.util.I18N;
1517

18+
import javax.annotation.Nullable;
19+
1620
public class AlleleHelper extends forestry.core.genetics.alleles.AlleleHelper {
1721
public static IAllele getAllele(EnumTemperature temperature) {
1822
return getAllele(getUid(temperature));
@@ -195,16 +199,18 @@ protected static String getUid(String key, String valueName) {
195199
return getUid(key, valueName, true);
196200
}
197201

202+
private static final Pattern PATTERN_REPLACEMENT = Pattern.compile("_");
203+
198204
private static String getUid(String key, String valueName, boolean needCapitalize) {
199205
if (needCapitalize) {
200206
valueName = WordUtils.capitalize(valueName.toLowerCase(Locale.ENGLISH));
201207
}
202-
valueName = valueName.replace("_", "");
208+
valueName = PATTERN_REPLACEMENT.matcher(valueName).replaceAll(EmptyHelper.EMPTY_STRING);
203209
return "forestry." + key + valueName;
204210
}
205211

206-
private static String toAlleleDisplay(String key, String valueName) {
207-
String name = valueName.toLowerCase().replace("_", "");
212+
private static String toAlleleDisplay(@Nullable String key, String valueName) {
213+
String name = PATTERN_REPLACEMENT.matcher(valueName.toLowerCase()).replaceAll(EmptyHelper.EMPTY_STRING);
208214
if (key == null) {
209215
return I18N.localise("forestry.allele." + name);
210216
}

core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import java.io.IOException;
66
import java.util.ArrayList;
77
import java.util.List;
8+
import java.util.regex.Pattern;
89

910
import binnie.core.api.gui.IPoint;
1011
import binnie.core.gui.KeyBindings;
1112
import binnie.core.gui.geometry.Point;
1213
import binnie.core.util.Log;
14+
import binnie.core.util.EmptyHelper;
1315
import net.minecraft.client.Minecraft;
1416
import net.minecraft.client.gui.FontRenderer;
1517
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -129,6 +131,8 @@ public void drawScreen(final int mouseX, final int mouseY, final float partialTi
129131
GlStateManager.enableDepth();
130132
}
131133

134+
private static final Pattern PATTERN_NBT_CONTENT = Pattern.compile(Tooltip.NBT_SEPARATOR + "(.*?)" + Tooltip.NBT_SEPARATOR);
135+
132136
public void renderTooltip(final Point mousePosition, final MinecraftTooltip tooltip) {
133137
final int mouseX = mousePosition.xPos();
134138
final int mouseY = mousePosition.yPos();
@@ -152,7 +156,7 @@ public void renderTooltip(final Point mousePosition, final MinecraftTooltip tool
152156
for (String textLine : textLines) {
153157
int textLineWidth = font.getStringWidth(textLine);
154158
if (textLine.contains(Tooltip.NBT_SEPARATOR)) {
155-
textLineWidth = 12 + font.getStringWidth(textLine.replaceAll(Tooltip.NBT_SEPARATOR + "(.*?)" + Tooltip.NBT_SEPARATOR, ""));
159+
textLineWidth = 12 + font.getStringWidth(PATTERN_NBT_CONTENT.matcher(textLine).replaceAll(EmptyHelper.EMPTY_STRING));
156160
}
157161
if (textLineWidth > tooltipTextWidth) {
158162
tooltipTextWidth = textLineWidth;
@@ -207,7 +211,7 @@ private void drawHoveringText(@Nonnull ItemStack itemStack, List<String> textLin
207211
for (String line : wrappedLine) {
208212
int lineWidth = font.getStringWidth(line);
209213
if (textLine.contains(Tooltip.NBT_SEPARATOR)) {
210-
lineWidth = 12 + font.getStringWidth(textLine.replaceAll(Tooltip.NBT_SEPARATOR + "(.*?)" + Tooltip.NBT_SEPARATOR, ""));
214+
lineWidth = 12 + font.getStringWidth(PATTERN_NBT_CONTENT.matcher(textLine).replaceAll(EmptyHelper.EMPTY_STRING));
211215
}
212216
if (lineWidth > wrappedTooltipWidth) {
213217
wrappedTooltipWidth = lineWidth;
@@ -262,7 +266,7 @@ private void drawHoveringText(@Nonnull ItemStack itemStack, List<String> textLin
262266
}
263267
if (line.contains(Tooltip.NBT_SEPARATOR)) {
264268
drawItem(line, tooltipX, tooltipY);
265-
line = " " + line.replaceAll(Tooltip.NBT_SEPARATOR + "(.*?)" + Tooltip.NBT_SEPARATOR, "");
269+
line = " " + PATTERN_NBT_CONTENT.matcher(line).replaceAll(EmptyHelper.EMPTY_STRING);
266270
}
267271
font.drawStringWithShadow(line, tooltipX, tooltipY, -1);
268272
if (lineNumber + 1 == titleLinesCount) {

core/src/main/java/binnie/core/network/BinnieCorePacketID.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void onMessage(final MessageBinnie message, final MessageContext context)
5858
final TileEntity tile = packet4.getTarget(BinnieCore.getBinnieProxy().getWorld());
5959
if (tile != null && packet4.getTagCompound() != null) {
6060
final IMachine machine = Machine.getMachine(tile);
61-
if (machine != null && machine instanceof INetwork.TilePacketSync) {
61+
if (machine instanceof INetwork.TilePacketSync) {
6262
((INetwork.TilePacketSync) machine).syncFromNBT(packet4.getTagCompound());
6363
}
6464
}

0 commit comments

Comments
 (0)