mirror of
https://github.com/GTNewHorizons/EnderCore.git
synced 2026-11-19 11:49:11 +00:00
Remove lombok dependency
And there was much rejoicing, yadda yadda, have fun everyone
This commit is contained in:
1 parent
cc362a74ad
commit
90bc31b8ca
41 files changed
+623
-334
No files matched your search
@@ -7,10 +7,6 @@ buildscript {
|
||||
dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' }
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'net.franz-becker.gradle-lombok' version '1.5'
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'curseforge'
|
||||
@@ -44,23 +40,6 @@ repositories {
|
||||
maven { url = "http://chickenbones.net/maven/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "codechicken:NotEnoughItems:${minecraft_version}-${NEI_version}:dev"
|
||||
}
|
||||
|
||||
lombok {
|
||||
version = "1.16.6"
|
||||
sha256 = "e0a471be03e1e6b02bf019480cec7a3ac9801702bf7bf62f15d077ad4df8dd5d"
|
||||
}
|
||||
|
||||
import net.franz_becker.gradle.lombok.task.DelombokTask
|
||||
|
||||
task delombok(type: DelombokTask) {
|
||||
args("src/main/java", "-d", "build/sources/delomboked/java")
|
||||
}
|
||||
|
||||
tasks.eclipse.dependsOn installLombok
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
@@ -98,10 +77,6 @@ jar {
|
||||
}
|
||||
}
|
||||
|
||||
javadoc {
|
||||
source = projectDir.path + "/build/sources/delomboked/java"
|
||||
}
|
||||
|
||||
task sourceJar(type: Jar) {
|
||||
from sourceSets.main.allSource
|
||||
classifier = 'sources'
|
||||
@@ -129,7 +104,6 @@ if (JavaVersion.current().isJava8Compatible()) {
|
||||
}
|
||||
}
|
||||
|
||||
javadoc.dependsOn delombok
|
||||
build.dependsOn sourceJar, deobfJar, apiJar, javadoc
|
||||
|
||||
publishing {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.enderio.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.minecraft.command.CommandHandler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
@@ -28,6 +28,7 @@ import com.enderio.core.common.network.EnderPacketHandler;
|
||||
import com.enderio.core.common.util.EnderFileUtils;
|
||||
import com.enderio.core.common.util.PermanentCache;
|
||||
import com.enderio.core.common.util.TextureErrorRemover;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
@@ -61,7 +62,6 @@ public class EnderCore implements IEnderMod {
|
||||
public List<IConfigHandler> configs = Lists.newArrayList();
|
||||
|
||||
@EventHandler
|
||||
@SneakyThrows
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
if (Loader.isModLoaded("ttCore")) {
|
||||
proxy.throwModCompatibilityError(lang.localize("error.ttcore.1"), lang.localize("error.ttcore.2"), lang.localize("error.ttcore.3"));
|
||||
@@ -76,7 +76,11 @@ public class EnderCore implements IEnderMod {
|
||||
ConfigHandler.configFile = new File(ConfigHandler.enderConfigFolder.getPath() + "/" + event.getSuggestedConfigurationFile().getName());
|
||||
|
||||
if (!ConfigHandler.configFile.exists() && event.getSuggestedConfigurationFile().exists()) {
|
||||
FileUtils.copyFile(event.getSuggestedConfigurationFile(), ConfigHandler.configFile);
|
||||
try {
|
||||
FileUtils.copyFile(event.getSuggestedConfigurationFile(), ConfigHandler.configFile);
|
||||
} catch (IOException e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
EnderFileUtils.safeDelete(event.getSuggestedConfigurationFile());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.enderio.core.api.client.render;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -20,11 +19,15 @@ public interface IWidgetMap {
|
||||
|
||||
void render(IWidgetIcon widget, double x, double y, double width, double height, double zLevel, boolean doDraw, boolean flipY);
|
||||
|
||||
@RequiredArgsConstructor
|
||||
static class WidgetMapImpl implements IWidgetMap {
|
||||
|
||||
private final int size;
|
||||
private final ResourceLocation res;
|
||||
|
||||
public WidgetMapImpl(int size, ResourceLocation res) {
|
||||
this.size = size;
|
||||
this.res = res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
|
||||
@@ -4,16 +4,17 @@ import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.enderio.core.EnderCore;
|
||||
import com.enderio.core.api.common.config.IConfigHandler;
|
||||
import com.enderio.core.common.config.ConfigHandler;
|
||||
import com.enderio.core.common.config.AbstractConfigHandler.Section;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
import com.enderio.core.EnderCore;
|
||||
import com.enderio.core.api.common.config.IConfigHandler;
|
||||
import com.enderio.core.common.config.AbstractConfigHandler.Section;
|
||||
import com.enderio.core.common.config.ConfigHandler;
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import cpw.mods.fml.client.config.GuiConfig;
|
||||
import cpw.mods.fml.client.config.IConfigElement;
|
||||
|
||||
@@ -118,9 +119,12 @@ public class BaseConfigGui extends GuiConfig {
|
||||
super(getProp(other));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static Property getProp(IConfigElement other) {
|
||||
return (Property) _prop.get(other);
|
||||
try {
|
||||
return (Property) _prop.get(other);
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.enderio.core.client.gui.bettermodlist;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
|
||||
import com.enderio.core.common.Handlers.Handler;
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import cpw.mods.fml.client.GuiIngameModOptions;
|
||||
import cpw.mods.fml.client.GuiModList;
|
||||
@@ -29,18 +29,21 @@ public class EventHandlerGui {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SneakyThrows
|
||||
public void onGuiOpen(GuiOpenEvent event) {
|
||||
if (event.gui == null) {
|
||||
return;
|
||||
}
|
||||
if (event.gui.getClass() == GuiModList.class) {
|
||||
event.setCanceled(true);
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiEnhancedModList((GuiScreen) _mainMenu.get(event.gui)));
|
||||
}
|
||||
if (event.gui.getClass() == GuiIngameModOptions.class) {
|
||||
event.setCanceled(true);
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiEnhancedModList((GuiScreen) _parentScreen.get(event.gui)));
|
||||
try {
|
||||
if (event.gui.getClass() == GuiModList.class) {
|
||||
event.setCanceled(true);
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiEnhancedModList((GuiScreen) _mainMenu.get(event.gui)));
|
||||
}
|
||||
if (event.gui.getClass() == GuiIngameModOptions.class) {
|
||||
event.setCanceled(true);
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiEnhancedModList((GuiScreen) _parentScreen.get(event.gui)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,17 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.enderio.core.EnderCore;
|
||||
import com.enderio.core.common.config.ConfigHandler;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
import com.enderio.core.EnderCore;
|
||||
import com.enderio.core.common.config.ConfigHandler;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cpw.mods.fml.client.GuiModList;
|
||||
import cpw.mods.fml.client.GuiScrollingList;
|
||||
import cpw.mods.fml.client.GuiSlotModList;
|
||||
@@ -305,75 +306,108 @@ public class GuiEnhancedModList extends GuiModList {
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private void setMods() {
|
||||
List<ModContainer> mods = getMods();
|
||||
|
||||
ModContainer sel = getSelectedMod();
|
||||
boolean found = false;
|
||||
for (int i = 0; !found && i < mods.size(); i++) {
|
||||
if (sel == mods.get(i)) {
|
||||
_selected.setInt(this, i);
|
||||
found = true;
|
||||
try {
|
||||
for (int i = 0; !found && i < mods.size(); i++) {
|
||||
if (sel == mods.get(i)) {
|
||||
_selected.setInt(this, i);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
_selected.setInt(this, -1);
|
||||
_selectedMod.set(this, null);
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
_selected.setInt(this, -1);
|
||||
_selectedMod.set(this, null);
|
||||
}
|
||||
|
||||
_mods.set(this, getMods());
|
||||
sorted = false;
|
||||
_mods.set(this, getMods());
|
||||
sorted = false;
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private GuiSlotModList getGuiModList() {
|
||||
return (GuiSlotModList) _modList.get(this);
|
||||
try {
|
||||
return (GuiSlotModList) _modList.get(this);
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private int getGuiModListRight() {
|
||||
return _modListRight.getInt(getGuiModList());
|
||||
try {
|
||||
return _modListRight.getInt(getGuiModList());
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private void setGuiModListBottom(int bottom) {
|
||||
_modListBottom.set(getGuiModList(), bottom);
|
||||
try {
|
||||
_modListBottom.set(getGuiModList(), bottom);
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private int getGuiModListBottom() {
|
||||
return _modListBottom.getInt(getGuiModList());
|
||||
try {
|
||||
return _modListBottom.getInt(getGuiModList());
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
||||
private float getGuiModListScroll() {
|
||||
return _scrollDistance.getFloat(getGuiModList());
|
||||
try {
|
||||
return _scrollDistance.getFloat(getGuiModList());
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
||||
private void setGuiModListScroll(float scroll) {
|
||||
_scrollDistance.setFloat(getGuiModList(), scroll);
|
||||
try {
|
||||
_scrollDistance.setFloat(getGuiModList(), scroll);
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SneakyThrows
|
||||
private List<ModContainer> getMods() {
|
||||
return (List<ModContainer>) _modListMods.get(_modList.get(this));
|
||||
try {
|
||||
return (List<ModContainer>) _modListMods.get(_modList.get(this));
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private int getListWidth() {
|
||||
return _listWidth.getInt(this);
|
||||
try {
|
||||
return _listWidth.getInt(this);
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private ModContainer getSelectedMod() {
|
||||
return (ModContainer) _selectedMod.get(this);
|
||||
try {
|
||||
return (ModContainer) _selectedMod.get(this);
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private void setSelectedMod(ModContainer mod) {
|
||||
_selectedMod.set(this, mod);
|
||||
try {
|
||||
_selectedMod.set(this, mod);
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.enderio.core.client.gui.button;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import com.enderio.core.api.client.gui.IGuiScreen;
|
||||
@@ -33,10 +32,8 @@ public class CycleButton<T extends Enum<T> & ICycleEnum> extends IconButton {
|
||||
|
||||
private final T[] modes;
|
||||
|
||||
@Getter
|
||||
private T mode;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CycleButton(IGuiScreen gui, int id, int x, int y, Class<T> enumClass) {
|
||||
super(gui, id, x, y, null);
|
||||
modes = enumClass.getEnumConstants();
|
||||
@@ -72,6 +69,10 @@ public class CycleButton<T extends Enum<T> & ICycleEnum> extends IconButton {
|
||||
}
|
||||
setMode(modes[ord]);
|
||||
}
|
||||
|
||||
public T getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(T newMode) {
|
||||
if (mode == newMode) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.enderio.core.client.handlers;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import com.enderio.core.common.Handlers.Handler;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -10,8 +8,12 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
|
||||
@Handler
|
||||
public class ClientHandler {
|
||||
@Getter
|
||||
|
||||
private static int ticksElapsed;
|
||||
|
||||
public static int getTicksElapsed() {
|
||||
return ticksElapsed;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClientTick(ClientTickEvent event) {
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.enderio.core.client.handlers;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -32,15 +30,13 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import static com.enderio.core.common.config.ConfigHandler.showDurabilityTooltips;
|
||||
|
||||
@Handler
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class SpecialTooltipHandler {
|
||||
|
||||
public enum SpecialTooltipHandler {
|
||||
INSTANCE;
|
||||
|
||||
public interface ITooltipCallback extends IAdvancedTooltipProvider {
|
||||
boolean shouldHandleItem(ItemStack item);
|
||||
}
|
||||
|
||||
public static final SpecialTooltipHandler INSTANCE = new SpecialTooltipHandler();
|
||||
|
||||
private final List<ITooltipCallback> callbacks = Lists.newArrayList();
|
||||
|
||||
public void addCallback(ITooltipCallback callback) {
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
package com.enderio.core.client.render;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import com.enderio.core.api.client.render.IWidgetIcon;
|
||||
import com.enderio.core.api.client.render.IWidgetMap;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CustomWidgetIcon implements IWidgetIcon {
|
||||
|
||||
private final int x, y, width, height;
|
||||
@@ -17,4 +10,46 @@ public class CustomWidgetIcon implements IWidgetIcon {
|
||||
|
||||
private IWidgetIcon overlay;
|
||||
|
||||
public CustomWidgetIcon(int x, int y, int width, int height, IWidgetMap map, IWidgetIcon overlay) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.map = map;
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
public CustomWidgetIcon(int x, int y, int width, int height, IWidgetMap map) {
|
||||
this(x, y, width, height, map, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidgetMap getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidgetIcon getOverlay() {
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.enderio.core.client.render;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import com.enderio.core.EnderCore;
|
||||
import com.enderio.core.api.client.render.IWidgetIcon;
|
||||
import com.enderio.core.api.client.render.IWidgetMap;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EnderWidget implements IWidgetIcon {
|
||||
|
||||
BUTTON_BASE(0, 0),
|
||||
@@ -80,7 +76,40 @@ public enum EnderWidget implements IWidgetIcon {
|
||||
EnderWidget(int x, int y, int width, int height) {
|
||||
this(x, y, width, height, null);
|
||||
}
|
||||
|
||||
EnderWidget(int x, int y, int width, int height, IWidgetIcon overlay) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidgetIcon getOverlay() {
|
||||
return overlay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidgetMap getMap() {
|
||||
return map;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.enderio.core.client.render;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
@@ -10,14 +8,22 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SimpleModelRenderer implements ISimpleBlockRenderingHandler {
|
||||
private final Tessellator tes = Tessellator.instance;
|
||||
|
||||
private final WavefrontObject model;
|
||||
|
||||
@Getter
|
||||
private final int renderId;
|
||||
|
||||
public SimpleModelRenderer(WavefrontObject model, int renderId) {
|
||||
this.model = model;
|
||||
this.renderId = renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
package com.enderio.core.client.sound;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.minecraft.client.audio.ITickableSound;
|
||||
import net.minecraft.client.audio.PositionedSound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@Accessors(chain = true)
|
||||
public class BlockSound extends PositionedSound implements ITickableSound {
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
private boolean donePlaying = false;
|
||||
|
||||
public BlockSound(ResourceLocation p_i45103_1_) {
|
||||
super(p_i45103_1_);
|
||||
}
|
||||
|
||||
public boolean isDonePlaying() {
|
||||
return this.donePlaying;
|
||||
}
|
||||
|
||||
public BlockSound setDonePlaying(boolean donePlaying) {
|
||||
this.donePlaying = donePlaying;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockSound setVolume(float vol) {
|
||||
this.volume = vol;
|
||||
return this;
|
||||
|
||||
@@ -12,9 +12,6 @@ import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.enderio.core.EnderCore;
|
||||
@@ -33,7 +30,6 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import static com.enderio.core.common.Handlers.Handler.Inst.*;
|
||||
|
||||
@UtilityClass
|
||||
public class Handlers {
|
||||
|
||||
/**
|
||||
@@ -43,7 +39,6 @@ public class Handlers {
|
||||
* The order of the constants is the order they are tried. This is VERY
|
||||
* important!
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public enum HandlerType {
|
||||
|
||||
/**
|
||||
@@ -66,6 +61,11 @@ public class Handlers {
|
||||
*/
|
||||
FML("cpw.mods.fml", FMLCommonHandler.instance().bus());
|
||||
|
||||
private HandlerType(String eventIdentifier, EventBus bus) {
|
||||
this.eventIdentifier = eventIdentifier;
|
||||
this.bus = bus;
|
||||
}
|
||||
|
||||
public final String eventIdentifier;
|
||||
public final EventBus bus;
|
||||
}
|
||||
@@ -190,14 +190,14 @@ public class Handlers {
|
||||
packageSet.add(packageName);
|
||||
}
|
||||
|
||||
private boolean registered = false;
|
||||
private static boolean registered = false;
|
||||
|
||||
/**
|
||||
* For internal use only. Do not call. Callers will be sacked.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void register(FMLInitializationEvent event) {
|
||||
public static void register(FMLInitializationEvent event) {
|
||||
if (registered) {
|
||||
throw new IllegalStateException("I warned you!");
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public class Handlers {
|
||||
registered = true;
|
||||
}
|
||||
|
||||
private void registerHandler(Class<?> c, ASMData data, Handler handler) throws InstantiationException, IllegalAccessException {
|
||||
private static void registerHandler(Class<?> c, ASMData data, Handler handler) throws InstantiationException, IllegalAccessException {
|
||||
EnderCore.logger.info(String.format("[Handlers] Registering handler %s to busses: %s", c.getSimpleName(), Arrays.deepToString(handler.value())));
|
||||
|
||||
Object inst = tryInit(handler, c);
|
||||
@@ -256,7 +256,7 @@ public class Handlers {
|
||||
}
|
||||
}
|
||||
|
||||
private Object tryInit(Handler annot, Class<?> c) {
|
||||
private static Object tryInit(Handler annot, Class<?> c) {
|
||||
Inst pref = annot.getInstFrom();
|
||||
|
||||
// Silence all exceptions to trickle down to next if statement.
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.enderio.core.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
@Getter
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class Lang {
|
||||
|
||||
private static final String REGEX = "\\" + '|';
|
||||
@@ -19,6 +17,13 @@ public class Lang {
|
||||
this.prefix = locKey.concat(".");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The prefix assigned to this Lang object.
|
||||
*/
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the stored prefix to this string, separating with a period. Using this
|
||||
* method returns the string that is used for localizing if you passed this
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.enderio.core.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -10,9 +9,9 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@UtilityClass
|
||||
public class OreDict {
|
||||
public void registerVanilla() {
|
||||
public final class OreDict {
|
||||
|
||||
public static void registerVanilla() {
|
||||
safeRegister("barsIron", Blocks.iron_bars);
|
||||
safeRegister("blockHopper", Blocks.hopper);
|
||||
safeRegister("blockObsidian", Blocks.obsidian);
|
||||
@@ -20,7 +19,6 @@ public class OreDict {
|
||||
safeRegister("gravel", Blocks.gravel);
|
||||
safeRegister("chestWood", Blocks.chest);
|
||||
safeRegister("craftingTableWood", Blocks.crafting_table);
|
||||
|
||||
safeRegister("itemCoal", Items.coal);
|
||||
safeRegister("itemCharcoal", new ItemStack(Items.coal, 1, 1));
|
||||
safeRegister("pearlEnder", Items.ender_pearl);
|
||||
@@ -32,14 +30,12 @@ public class OreDict {
|
||||
safeRegister("itemGhastTear", Items.ghast_tear);
|
||||
safeRegister("dustGunpowder", Items.gunpowder);
|
||||
safeRegister("itemLeather", Items.leather);
|
||||
|
||||
safeRegister("slabWoodOak", new ItemStack(Blocks.wooden_slab, 1, 0));
|
||||
safeRegister("slabWoodSpruce", new ItemStack(Blocks.wooden_slab, 1, 1));
|
||||
safeRegister("slabWoodBirch", new ItemStack(Blocks.wooden_slab, 1, 2));
|
||||
safeRegister("slabWoodJungle", new ItemStack(Blocks.wooden_slab, 1, 3));
|
||||
safeRegister("slabWoodAcacia", new ItemStack(Blocks.wooden_slab, 1, 4));
|
||||
safeRegister("slabWoodDarkOak", new ItemStack(Blocks.wooden_slab, 1, 5));
|
||||
|
||||
safeRegister("slabStone", new ItemStack(Blocks.stone_slab, 1, 0));
|
||||
safeRegister("slabSandstone", new ItemStack(Blocks.stone_slab, 1, 1));
|
||||
safeRegister("slabCobblestone", new ItemStack(Blocks.stone_slab, 1, 3));
|
||||
@@ -49,26 +45,28 @@ public class OreDict {
|
||||
safeRegister("slabQuartz", new ItemStack(Blocks.stone_slab, 1, 7));
|
||||
}
|
||||
|
||||
public void safeRegister(String name, Block block) {
|
||||
public static void safeRegister(String name, Block block) {
|
||||
safeRegister(name, Item.getItemFromBlock(block));
|
||||
}
|
||||
|
||||
public void safeRegister(String name, Item item) {
|
||||
public static void safeRegister(String name, Item item) {
|
||||
safeRegister(name, new ItemStack(item));
|
||||
}
|
||||
|
||||
public void safeRegister(String name, ItemStack stack) {
|
||||
if (!isRegistered(stack, OreDictionary.getOres(name)))
|
||||
OreDictionary.registerOre(name, stack);
|
||||
public static void safeRegister(String name, ItemStack stack) {
|
||||
if (!isRegistered(stack, OreDictionary.getOres(name))) OreDictionary.registerOre(name, stack);
|
||||
}
|
||||
|
||||
private boolean isRegistered(ItemStack stack, ArrayList<ItemStack> toCheck) {
|
||||
private static boolean isRegistered(ItemStack stack, ArrayList<ItemStack> toCheck) {
|
||||
for (ItemStack check : toCheck) {
|
||||
if (stack != null && stack.getItem() == check.getItem()
|
||||
&& (stack.getItemDamage() == check.getItemDamage() || stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) {
|
||||
if (stack != null && stack.getItem() == check.getItem() && (stack.getItemDamage() == check.getItemDamage() || stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private OreDict() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package com.enderio.core.common.command;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
@@ -19,7 +17,6 @@ import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class CommandReloadConfigs extends CommandBase {
|
||||
public static final CommandReloadConfigs SERVER = new CommandReloadConfigs(Side.SERVER);
|
||||
public static final CommandReloadConfigs CLIENT = new CommandReloadConfigs(Side.CLIENT);
|
||||
@@ -40,6 +37,10 @@ public class CommandReloadConfigs extends CommandBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CommandReloadConfigs(Side side) {
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
|
||||
@@ -5,10 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Value;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
@@ -18,12 +15,12 @@ import com.enderio.core.common.util.RegisterTime;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.event.FMLStateEvent;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class CompatRegistry {
|
||||
@Value
|
||||
public enum CompatRegistry {
|
||||
INSTANCE;
|
||||
|
||||
private static class Registration {
|
||||
String[] modids;
|
||||
RegisterTime[] times;
|
||||
private final String[] modids;
|
||||
private final RegisterTime[] times;
|
||||
|
||||
private Registration(RegisterTime time, String... modids) {
|
||||
this.modids = modids;
|
||||
@@ -34,14 +31,53 @@ public class CompatRegistry {
|
||||
this.modids = modids;
|
||||
this.times = times;
|
||||
}
|
||||
|
||||
public String[] getModids() {
|
||||
return this.modids;
|
||||
}
|
||||
|
||||
public RegisterTime[] getTimes() {
|
||||
return this.times;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Generated("lombok")
|
||||
public boolean equals(final java.lang.Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof CompatRegistry.Registration)) return false;
|
||||
final Registration other = (Registration)o;
|
||||
if (!java.util.Arrays.deepEquals(this.getModids(), other.getModids())) return false;
|
||||
if (!java.util.Arrays.deepEquals(this.getTimes(), other.getTimes())) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Generated("lombok")
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
result = result * PRIME + java.util.Arrays.deepHashCode(this.getModids());
|
||||
result = result * PRIME + java.util.Arrays.deepHashCode(this.getTimes());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Generated("lombok")
|
||||
public java.lang.String toString() {
|
||||
return "CompatRegistry.Registration(modids=" + java.util.Arrays.deepToString(this.getModids()) + ", times=" + java.util.Arrays.deepToString(this.getTimes()) + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public static final CompatRegistry INSTANCE = new CompatRegistry();
|
||||
|
||||
|
||||
private Map<Registration, String> compatMap = new HashMap<Registration, String>();
|
||||
|
||||
@Getter
|
||||
private RegisterTime state = null;
|
||||
|
||||
private CompatRegistry() {
|
||||
}
|
||||
|
||||
public RegisterTime getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void registerCompat(RegisterTime time, String clazz, String... modids) {
|
||||
compatMap.put(new Registration(time, modids), clazz);
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import lombok.NonNull;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
@@ -213,12 +212,10 @@ public abstract class AbstractConfigHandler implements IConfigHandler {
|
||||
* @param sectionName
|
||||
* The name of the section
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* if {@code sectionName} is null
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code sectionName} is not valid
|
||||
*/
|
||||
protected void activateSection(@NonNull String sectionName) {
|
||||
protected void activateSection(String sectionName) {
|
||||
Section section = getSectionByName(sectionName);
|
||||
if (section == null) {
|
||||
throw new IllegalArgumentException("Section " + sectionName + " does not exist!");
|
||||
@@ -231,11 +228,8 @@ public abstract class AbstractConfigHandler implements IConfigHandler {
|
||||
*
|
||||
* @param section
|
||||
* The section to activate
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* if {@code section} is null
|
||||
*/
|
||||
protected void activateSection(@NonNull Section section) {
|
||||
protected void activateSection(Section section) {
|
||||
activeSection = section;
|
||||
}
|
||||
|
||||
@@ -246,11 +240,8 @@ public abstract class AbstractConfigHandler implements IConfigHandler {
|
||||
* The name of the section
|
||||
* @return A section object representing the section in your config with this
|
||||
* name
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* if {@code sectionName} is null
|
||||
*/
|
||||
protected Section getSectionByName(@NonNull String sectionName) {
|
||||
protected Section getSectionByName(String sectionName) {
|
||||
for (Section s : sections) {
|
||||
if (s.name.equalsIgnoreCase(sectionName)) {
|
||||
return s;
|
||||
|
||||
@@ -6,9 +6,6 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import com.enderio.core.common.util.EnderFileUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
@@ -45,11 +42,22 @@ public class JsonConfigReader<T> implements Iterable<T> {
|
||||
* <b>assetPath</b> is the path to your default json file. This includes the
|
||||
* /modid part and whatever subfolders follow.
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public static class ModToken {
|
||||
private Class<?> mainClass;
|
||||
private String assetPath;
|
||||
|
||||
public ModToken(Class<?> mainClass, String assetPath) {
|
||||
this.mainClass = mainClass;
|
||||
this.assetPath = assetPath;
|
||||
}
|
||||
|
||||
public Class<?> getMainClass() {
|
||||
return mainClass;
|
||||
}
|
||||
|
||||
public String getAssetPath() {
|
||||
return assetPath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,13 +4,15 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -30,13 +32,17 @@ public class PacketConfigSync implements IMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteArrayOutputStream obj = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(obj);
|
||||
ObjectOutputStream objStream = new ObjectOutputStream(gzip);
|
||||
objStream.writeObject(configValues);
|
||||
objStream.close();
|
||||
|
||||
try {
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(obj);
|
||||
ObjectOutputStream objStream = new ObjectOutputStream(gzip);
|
||||
objStream.writeObject(configValues);
|
||||
objStream.close();
|
||||
} catch (IOException e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
|
||||
buf.writeShort(obj.size());
|
||||
buf.writeBytes(obj.toByteArray());
|
||||
@@ -46,7 +52,6 @@ public class PacketConfigSync implements IMessage {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
short len = buf.readShort();
|
||||
byte[] compressedBody = new byte[len];
|
||||
@@ -54,9 +59,13 @@ public class PacketConfigSync implements IMessage {
|
||||
for (short i = 0; i < len; i++)
|
||||
compressedBody[i] = buf.readByte();
|
||||
|
||||
ObjectInputStream obj = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(compressedBody)));
|
||||
configValues = (Map<String, Object>) obj.readObject();
|
||||
obj.close();
|
||||
try {
|
||||
ObjectInputStream obj = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(compressedBody)));
|
||||
configValues = (Map<String, Object>) obj.readObject();
|
||||
obj.close();
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
|
||||
modid = ByteBufUtils.readUTF8String(buf);
|
||||
}
|
||||
|
||||
@@ -4,29 +4,46 @@ import java.io.Serializable;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.config.Property.Type;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import com.enderio.core.common.config.ConfigProcessor.ITypeAdapter;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@SuppressWarnings({ "serial", "unchecked" })
|
||||
public abstract class TypeAdapterBase<ACTUAL, BASE> implements ITypeAdapter<ACTUAL, BASE> {
|
||||
private final TypeToken<ACTUAL> actualType;
|
||||
private final Property.Type type;
|
||||
private final Class<?> primitiveType;
|
||||
|
||||
public TypeAdapterBase(TypeToken<ACTUAL> actualType, Property.Type type, Class<?> primitiveType) {
|
||||
this.actualType = actualType;
|
||||
this.type = type;
|
||||
this.primitiveType = primitiveType;
|
||||
}
|
||||
|
||||
public TypeAdapterBase(TypeToken<ACTUAL> actualType, Property.Type baseType) {
|
||||
this(actualType, baseType, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeToken<ACTUAL> getActualType() {
|
||||
return actualType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property.Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getPrimitiveType() {
|
||||
return primitiveType;
|
||||
}
|
||||
|
||||
public static final class TypeAdapterSame<TYPE> extends TypeAdapterBase<TYPE, TYPE> {
|
||||
public TypeAdapterSame(TypeToken<TYPE> actual, Property.Type base) {
|
||||
super(actual, base);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.enderio.core.common.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import cpw.mods.fml.client.event.ConfigChangedEvent;
|
||||
|
||||
/**
|
||||
@@ -20,12 +19,15 @@ import cpw.mods.fml.client.event.ConfigChangedEvent;
|
||||
* considered a failure!</b>
|
||||
*/
|
||||
public class ConfigFileChangedEvent extends ConfigChangedEvent {
|
||||
@Getter
|
||||
private boolean successful;
|
||||
|
||||
public ConfigFileChangedEvent(String modID) {
|
||||
super(modID, "null", true, false);
|
||||
}
|
||||
|
||||
public boolean isSuccessful() {
|
||||
return this.successful;
|
||||
}
|
||||
|
||||
public void setSuccessful() {
|
||||
this.successful = true;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.enderio.core.common.event;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -16,10 +15,13 @@ import cpw.mods.fml.common.eventhandler.Event;
|
||||
* <br>
|
||||
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
**/
|
||||
@RequiredArgsConstructor
|
||||
public class ItemStackEvent extends Event {
|
||||
public final ItemStack item;
|
||||
|
||||
public ItemStackEvent(ItemStack item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* ItemEnchantabilityEvent is fired when calculating an Item's enchantability. <br>
|
||||
* <br>
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.enderio.core.common.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
@@ -20,7 +19,6 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@Handler
|
||||
public class RightClickCropHandler {
|
||||
@NoArgsConstructor
|
||||
public static class PlantInfo {
|
||||
public String seed;
|
||||
public String block;
|
||||
@@ -29,6 +27,9 @@ public class RightClickCropHandler {
|
||||
|
||||
private transient ItemStack seedStack;
|
||||
private transient Block blockInst;
|
||||
|
||||
public PlantInfo() {
|
||||
}
|
||||
|
||||
public PlantInfo(String seed, String block, int meta, int resetMeta) {
|
||||
this.seed = seed;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.enderio.core.common.handlers;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -21,6 +20,7 @@ import net.minecraftforge.event.world.BlockEvent.BreakEvent;
|
||||
import com.enderio.core.common.Handlers.Handler;
|
||||
import com.enderio.core.common.enchant.EnchantXPBoost;
|
||||
import com.enderio.core.common.util.Scheduler;
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
@@ -81,11 +81,14 @@ public class XPBoostHandler {
|
||||
return getXPBoost(killed, player, getXPBoostLevel(player.getCurrentEquippedItem()));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private int getXPBoost(EntityLivingBase killed, EntityPlayer player, int level) {
|
||||
if (level >= 0) {
|
||||
int xp = (Integer) getExperiencePoints.invoke(killed, player);
|
||||
return getXPBoost(xp, level);
|
||||
try {
|
||||
int xp = (Integer) getExperiencePoints.invoke(killed, player);
|
||||
return getXPBoost(xp, level);
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.enderio.core.common.transform;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -18,9 +17,8 @@ import com.enderio.core.common.event.ArrowUpdateEvent;
|
||||
import com.enderio.core.common.event.ItemStackEvent.ItemEnchantabilityEvent;
|
||||
import com.enderio.core.common.event.ItemStackEvent.ItemRarityEvent;
|
||||
|
||||
@UtilityClass
|
||||
public class EnderCoreMethods {
|
||||
public boolean hasVoidParticles(WorldType type, boolean hasSky) {
|
||||
public static boolean hasVoidParticles(WorldType type, boolean hasSky) {
|
||||
if (ConfigHandler.disableVoidFog == 0) {
|
||||
return type != WorldType.FLAT && !hasSky;
|
||||
} else if (ConfigHandler.disableVoidFog == 1) {
|
||||
@@ -30,28 +28,28 @@ public class EnderCoreMethods {
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxAnvilCost() {
|
||||
public static int getMaxAnvilCost() {
|
||||
return ConfigHandler.anvilMaxLevel;
|
||||
}
|
||||
|
||||
public int getItemEnchantability(ItemStack stack, int base) {
|
||||
public static int getItemEnchantability(ItemStack stack, int base) {
|
||||
ItemEnchantabilityEvent event = new ItemEnchantabilityEvent(stack, base);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.enchantability;
|
||||
}
|
||||
|
||||
public EnumRarity getItemRarity(ItemStack stack) {
|
||||
public static EnumRarity getItemRarity(ItemStack stack) {
|
||||
ItemRarityEvent event = new ItemRarityEvent(stack, stack.getItem().getRarity(stack));
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.rarity;
|
||||
}
|
||||
|
||||
public void onArrowUpdate(EntityArrow entity) {
|
||||
public static void onArrowUpdate(EntityArrow entity) {
|
||||
MinecraftForge.EVENT_BUS.post(new ArrowUpdateEvent(entity));
|
||||
}
|
||||
|
||||
// mostly copied from ContainerFurnace
|
||||
public ItemStack transferStackInSlot(ContainerFurnace inv, EntityPlayer p_82846_1_, int p_82846_2_) {
|
||||
public static ItemStack transferStackInSlot(ContainerFurnace inv, EntityPlayer p_82846_1_, int p_82846_2_) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot) inv.inventorySlots.get(p_82846_2_);
|
||||
|
||||
@@ -109,7 +107,7 @@ public class EnderCoreMethods {
|
||||
}
|
||||
|
||||
// copied from Container
|
||||
private boolean mergeItemStack(Container inv, ItemStack p_75135_1_, int p_75135_2_, int p_75135_3_, boolean p_75135_4_) {
|
||||
private static boolean mergeItemStack(Container inv, ItemStack p_75135_1_, int p_75135_2_, int p_75135_3_, boolean p_75135_4_) {
|
||||
boolean flag1 = false;
|
||||
int k = p_75135_2_;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -21,14 +20,19 @@ import org.objectweb.asm.tree.VarInsnNode;
|
||||
import com.enderio.core.EnderCore;
|
||||
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
@MCVersion(value = "1.7.10")
|
||||
public class EnderCoreTransformer implements IClassTransformer {
|
||||
@AllArgsConstructor
|
||||
protected static class ObfSafeName {
|
||||
private String deobf, srg;
|
||||
|
||||
public ObfSafeName(String deobf, String srg) {
|
||||
this.deobf = deobf;
|
||||
this.srg = srg;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return EnderCorePlugin.runtimeDeobfEnabled ? srg : deobf;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ package com.enderio.core.common.tweaks;
|
||||
|
||||
import com.enderio.core.common.config.ConfigHandler;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public abstract class Tweak {
|
||||
private String name, comment;
|
||||
|
||||
@@ -16,5 +13,13 @@ public abstract class Tweak {
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public abstract void load();
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.enderio.core.common.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Wither;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -16,15 +16,19 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class BlockCoord {
|
||||
@Wither
|
||||
|
||||
public final int x, y, z;
|
||||
|
||||
public BlockCoord() {
|
||||
this(0, 0, 0);
|
||||
}
|
||||
|
||||
public BlockCoord(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public BlockCoord(double x, double y, double z) {
|
||||
this(MathHelper.floor_double(x), MathHelper.floor_double(y), MathHelper.floor_double(z));
|
||||
@@ -124,4 +128,48 @@ public class BlockCoord {
|
||||
public String toString() {
|
||||
return "X: " + x + " Y: " + y + " Z: " + z;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Generated("lombok")
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof BlockCoord)) return false;
|
||||
final BlockCoord other = (BlockCoord)o;
|
||||
if (!other.canEqual((Object)this)) return false;
|
||||
if (this.x != other.x) return false;
|
||||
if (this.y != other.y) return false;
|
||||
if (this.z != other.z) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Generated("lombok")
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof BlockCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Generated("lombok")
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
result = result * PRIME + this.x;
|
||||
result = result * PRIME + this.y;
|
||||
result = result * PRIME + this.z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Generated("lombok")
|
||||
public BlockCoord withX(final int x) {
|
||||
return this.x == x ? this : new BlockCoord(x, this.y, this.z);
|
||||
}
|
||||
|
||||
@Generated("lombok")
|
||||
public BlockCoord withY(final int y) {
|
||||
return this.y == y ? this : new BlockCoord(this.x, y, this.z);
|
||||
}
|
||||
|
||||
@Generated("lombok")
|
||||
public BlockCoord withZ(final int z) {
|
||||
return this.z == z ? this : new BlockCoord(this.x, this.y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.enderio.core.common.util;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Value;
|
||||
import lombok.experimental.Wither;
|
||||
|
||||
/**
|
||||
* An object to represent a bounds limit on a property.
|
||||
*
|
||||
@@ -14,20 +10,78 @@ import lombok.experimental.Wither;
|
||||
* The type of the bound.
|
||||
*/
|
||||
@Immutable
|
||||
@Value
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
//@AllArgsConstructor(staticName = "of") // Broken with javac 1.8...
|
||||
public class Bound<T extends Number & Comparable<T>> {
|
||||
public static final Bound<Double> MAX_BOUND = Bound.of(Double.MIN_VALUE, Double.MAX_VALUE);
|
||||
public final class Bound<T extends Number & Comparable<T>> {
|
||||
|
||||
@Wither
|
||||
public T min, max;
|
||||
public static final Bound<Double> MAX_BOUND = Bound.of(Double.MIN_VALUE, Double.MAX_VALUE);
|
||||
|
||||
public static <T extends Number & Comparable<T>> Bound<T> of(T min, T max) {
|
||||
return new Bound<T>(min, max);
|
||||
}
|
||||
|
||||
public final T min;
|
||||
public final T max;
|
||||
|
||||
private Bound(final T min, final T max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public T getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public T getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public T clamp(T val) {
|
||||
return val.compareTo(min) < 0 ? min : val.compareTo(max) > 0 ? max : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Generated("lombok")
|
||||
public boolean equals(final java.lang.Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof Bound))
|
||||
return false;
|
||||
final Bound<?> other = (Bound<?>) o;
|
||||
final java.lang.Object this$min = this.getMin();
|
||||
final java.lang.Object other$min = other.getMin();
|
||||
if (this$min == null ? other$min != null : !this$min.equals(other$min))
|
||||
return false;
|
||||
final java.lang.Object this$max = this.getMax();
|
||||
final java.lang.Object other$max = other.getMax();
|
||||
if (this$max == null ? other$max != null : !this$max.equals(other$max))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Generated("lombok")
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final java.lang.Object $min = this.getMin();
|
||||
result = result * PRIME + ($min == null ? 43 : $min.hashCode());
|
||||
final java.lang.Object $max = this.getMax();
|
||||
result = result * PRIME + ($max == null ? 43 : $max.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Generated("lombok")
|
||||
public java.lang.String toString() {
|
||||
return "Bound(min=" + this.getMin() + ", max=" + this.getMax() + ")";
|
||||
}
|
||||
|
||||
@Generated("lombok")
|
||||
public Bound<T> withMin(final T min) {
|
||||
return this.min == min ? this : new Bound<T>(min, this.max);
|
||||
}
|
||||
|
||||
@Generated("lombok")
|
||||
public Bound<T> withMax(final T max) {
|
||||
return this.max == max ? this : new Bound<T>(this.min, max);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.enderio.core.common.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiNewChat;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -19,14 +17,16 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
@UtilityClass
|
||||
public class ChatUtil {
|
||||
|
||||
@NoArgsConstructor
|
||||
public static class PacketNoSpamChat implements IMessage {
|
||||
|
||||
private IChatComponent[] chatLines;
|
||||
|
||||
public PacketNoSpamChat() {
|
||||
chatLines = new IChatComponent[0];
|
||||
}
|
||||
|
||||
private PacketNoSpamChat(IChatComponent... lines) {
|
||||
// this is guaranteed to be >1 length by accessing methods
|
||||
this.chatLines = lines;
|
||||
@@ -61,7 +61,7 @@ public class ChatUtil {
|
||||
private static final int DELETION_ID = 8675309;
|
||||
private static int lastAdded;
|
||||
|
||||
private void sendNoSpamMessages(IChatComponent[] messages) {
|
||||
private static void sendNoSpamMessages(IChatComponent[] messages) {
|
||||
GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();
|
||||
for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++) {
|
||||
chat.deleteChatLine(i);
|
||||
@@ -79,14 +79,14 @@ public class ChatUtil {
|
||||
* The string to wrap.
|
||||
* @return An {@link IChatComponent} containing the string.
|
||||
*/
|
||||
public IChatComponent wrap(String s) {
|
||||
public static IChatComponent wrap(String s) {
|
||||
return new ChatComponentText(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #wrap(String)
|
||||
*/
|
||||
public IChatComponent[] wrap(String... s) {
|
||||
public static IChatComponent[] wrap(String... s) {
|
||||
IChatComponent[] ret = new IChatComponent[s.length];
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = wrap(s[i]);
|
||||
@@ -102,7 +102,7 @@ public class ChatUtil {
|
||||
* @param args
|
||||
* The args to apply to the format
|
||||
*/
|
||||
public IChatComponent wrapFormatted(String s, Object... args) {
|
||||
public static IChatComponent wrapFormatted(String s, Object... args) {
|
||||
return new ChatComponentTranslation(s, args);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ChatUtil {
|
||||
* @param lines
|
||||
* The lines to send
|
||||
*/
|
||||
public void sendChat(EntityPlayer player, String... lines) {
|
||||
public static void sendChat(EntityPlayer player, String... lines) {
|
||||
sendChat(player, wrap(lines));
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class ChatUtil {
|
||||
*
|
||||
* @see #sendChat(EntityPlayer, String...)
|
||||
*/
|
||||
public void sendChatUnloc(EntityPlayer player, Lang lang, String... unlocLines) {
|
||||
public static void sendChatUnloc(EntityPlayer player, Lang lang, String... unlocLines) {
|
||||
sendChat(player, lang.localizeAll(lang, unlocLines));
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class ChatUtil {
|
||||
* @param lines
|
||||
* The {@link IChatComponent chat components} to send.yes
|
||||
*/
|
||||
public void sendChat(EntityPlayer player, IChatComponent... lines) {
|
||||
public static void sendChat(EntityPlayer player, IChatComponent... lines) {
|
||||
for (IChatComponent c : lines) {
|
||||
player.addChatComponentMessage(c);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class ChatUtil {
|
||||
*
|
||||
* @see #sendNoSpamClient(String...)
|
||||
*/
|
||||
public void sendNoSpamClientUnloc(Lang lang, String... unlocLines) {
|
||||
public static void sendNoSpamClientUnloc(Lang lang, String... unlocLines) {
|
||||
sendNoSpamClient(lang.localizeAll(lang, unlocLines));
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ChatUtil {
|
||||
* The chat lines to send
|
||||
* @see #wrap(String)
|
||||
*/
|
||||
public void sendNoSpamClient(String... lines) {
|
||||
public static void sendNoSpamClient(String... lines) {
|
||||
sendNoSpamClient(wrap(lines));
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public class ChatUtil {
|
||||
*
|
||||
* @see #sendNoSpam(EntityPlayerMP, IChatComponent...)
|
||||
*/
|
||||
public void sendNoSpamClient(IChatComponent... lines) {
|
||||
public static void sendNoSpamClient(IChatComponent... lines) {
|
||||
sendNoSpamMessages(lines);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public class ChatUtil {
|
||||
*
|
||||
* @see #sendNoSpam(EntityPlayer, String...)
|
||||
*/
|
||||
public void sendNoSpamUnloc(EntityPlayer player, Lang lang, String... unlocLines) {
|
||||
public static void sendNoSpamUnloc(EntityPlayer player, Lang lang, String... unlocLines) {
|
||||
sendNoSpam(player, lang.localizeAll(lang, unlocLines));
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public class ChatUtil {
|
||||
* @see #wrap(String)
|
||||
* @see #sendNoSpam(EntityPlayer, IChatComponent...)
|
||||
*/
|
||||
public void sendNoSpam(EntityPlayer player, String... lines) {
|
||||
public static void sendNoSpam(EntityPlayer player, String... lines) {
|
||||
sendNoSpam(player, wrap(lines));
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class ChatUtil {
|
||||
*
|
||||
* @see #sendNoSpam(EntityPlayerMP, IChatComponent...)
|
||||
*/
|
||||
public void sendNoSpam(EntityPlayer player, IChatComponent... lines) {
|
||||
public static void sendNoSpam(EntityPlayer player, IChatComponent... lines) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
sendNoSpam((EntityPlayerMP) player, lines);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ public class ChatUtil {
|
||||
*
|
||||
* @see #sendNoSpam(EntityPlayerMP, String...)
|
||||
*/
|
||||
public void sendNoSpamUnloc(EntityPlayerMP player, Lang lang, String... unlocLines) {
|
||||
public static void sendNoSpamUnloc(EntityPlayerMP player, Lang lang, String... unlocLines) {
|
||||
sendNoSpam(player, lang.localizeAll(lang, unlocLines));
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class ChatUtil {
|
||||
* @see #wrap(String)
|
||||
* @see #sendNoSpam(EntityPlayerMP, IChatComponent...)
|
||||
*/
|
||||
public void sendNoSpam(EntityPlayerMP player, String... lines) {
|
||||
public static void sendNoSpam(EntityPlayerMP player, String... lines) {
|
||||
sendNoSpam(player, wrap(lines));
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public class ChatUtil {
|
||||
* @param lines
|
||||
* The chat lines to send.
|
||||
*/
|
||||
public void sendNoSpam(EntityPlayerMP player, IChatComponent... lines) {
|
||||
public static void sendNoSpam(EntityPlayerMP player, IChatComponent... lines) {
|
||||
if (lines.length > 0) {
|
||||
EnderPacketHandler.INSTANCE.sendTo(new PacketNoSpamChat(lines), player);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.enderio.core.common.util;
|
||||
|
||||
import lombok.NonNull;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CreativeTabsCustom extends CreativeTabs {
|
||||
@NonNull
|
||||
private ItemStack displayStack;
|
||||
|
||||
public CreativeTabsCustom(String unloc) {
|
||||
|
||||
@@ -26,10 +26,7 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.FileFilterUtils;
|
||||
@@ -37,10 +34,9 @@ import org.apache.commons.io.filefilter.FileFilterUtils;
|
||||
import com.enderio.core.EnderCore;
|
||||
import com.enderio.core.common.config.ConfigHandler;
|
||||
|
||||
@UtilityClass
|
||||
public class EnderFileUtils {
|
||||
public final FileFilter pngFilter = FileFilterUtils.suffixFileFilter(".png");
|
||||
public final FileFilter langFilter = FileFilterUtils.suffixFileFilter(".lang");
|
||||
public static final FileFilter pngFilter = FileFilterUtils.suffixFileFilter(".png");
|
||||
public static final FileFilter langFilter = FileFilterUtils.suffixFileFilter(".lang");
|
||||
|
||||
/**
|
||||
* @param jarClass
|
||||
@@ -51,7 +47,7 @@ public class EnderFileUtils {
|
||||
* @param to
|
||||
* - File to copy to
|
||||
*/
|
||||
public void copyFromJar(Class<?> jarClass, String filename, File to) {
|
||||
public static void copyFromJar(Class<?> jarClass, String filename, File to) {
|
||||
EnderCore.logger.info("Copying file " + filename + " from jar");
|
||||
URL url = jarClass.getResource("/assets/" + filename);
|
||||
|
||||
@@ -74,8 +70,8 @@ public class EnderFileUtils {
|
||||
*
|
||||
* @return The folder extracted to
|
||||
*/
|
||||
@NonNull
|
||||
public File extractZip(File zip) {
|
||||
@Nonnull
|
||||
public static File extractZip(File zip) {
|
||||
String zipPath = zip.getParent() + "/extracted";
|
||||
File temp = new File(zipPath);
|
||||
temp.mkdir();
|
||||
@@ -146,7 +142,7 @@ public class EnderFileUtils {
|
||||
* @throws IOException
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public void zipFolderContents(File directory, File zipfile) throws IOException {
|
||||
public static void zipFolderContents(File directory, File zipfile) throws IOException {
|
||||
URI base = directory.toURI();
|
||||
Deque<File> queue = new LinkedList<File>();
|
||||
queue.push(directory);
|
||||
@@ -176,7 +172,7 @@ public class EnderFileUtils {
|
||||
}
|
||||
|
||||
/** @see #zipFolderContents(File, File) */
|
||||
private void copy(InputStream in, OutputStream out) throws IOException {
|
||||
private static void copy(InputStream in, OutputStream out) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
while (true) {
|
||||
int readCount = in.read(buffer);
|
||||
@@ -188,7 +184,7 @@ public class EnderFileUtils {
|
||||
}
|
||||
|
||||
/** @see #zipFolderContents(File, File) */
|
||||
private void copy(File file, OutputStream out) throws IOException {
|
||||
private static void copy(File file, OutputStream out) throws IOException {
|
||||
InputStream in = new FileInputStream(file);
|
||||
try {
|
||||
copy(in, out);
|
||||
@@ -197,8 +193,8 @@ public class EnderFileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public File writeToFile(String filepath, String json) {
|
||||
@Nonnull
|
||||
public static File writeToFile(String filepath, String json) {
|
||||
File file = new File(filepath);
|
||||
|
||||
try {
|
||||
@@ -213,8 +209,8 @@ public class EnderFileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public void safeDelete(File file) {
|
||||
@Nonnull
|
||||
public static void safeDelete(File file) {
|
||||
try {
|
||||
file.delete();
|
||||
} catch (Exception e) {
|
||||
@@ -222,8 +218,8 @@ public class EnderFileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public void safeDeleteDirectory(File file) {
|
||||
@Nonnull
|
||||
public static void safeDeleteDirectory(File file) {
|
||||
try {
|
||||
FileUtils.deleteDirectory(file);
|
||||
} catch (Exception e) {
|
||||
@@ -231,12 +227,14 @@ public class EnderFileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@NonNull
|
||||
public void loadLangFiles(File directory) {
|
||||
for (File file : directory.listFiles(langFilter)) {
|
||||
StringTranslate.inject(new FileInputStream(file));
|
||||
}
|
||||
/**
|
||||
* I don't think this ever worked.
|
||||
*
|
||||
* @param directory
|
||||
*/
|
||||
@Deprecated
|
||||
public static void loadLangFiles(File directory) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,7 +253,7 @@ public class EnderFileUtils {
|
||||
* - The setting to change it to
|
||||
* @return whether anything changed
|
||||
*/
|
||||
public boolean manuallyChangeConfigValue(String filePathFromConfigFolder, String prefix, String from, String to) {
|
||||
public static boolean manuallyChangeConfigValue(String filePathFromConfigFolder, String prefix, String from, String to) {
|
||||
File config = new File(ConfigHandler.configFolder.getAbsolutePath() + "/" + filePathFromConfigFolder);
|
||||
boolean found = false;
|
||||
|
||||
@@ -307,7 +305,7 @@ public class EnderFileUtils {
|
||||
* config values, for instance using
|
||||
* <code>Boolean.parseBoolean(String)</code>
|
||||
*/
|
||||
public String manuallyGetConfigValue(String filePathFromConfigFolder, String key) {
|
||||
public static String manuallyGetConfigValue(String filePathFromConfigFolder, String key) {
|
||||
File config = new File(ConfigHandler.configFolder.getAbsolutePath() + "/" + filePathFromConfigFolder);
|
||||
Scanner scan = null;
|
||||
|
||||
|
||||
@@ -3,14 +3,13 @@ package com.enderio.core.common.util;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
@@ -25,11 +24,10 @@ import cpw.mods.fml.common.registry.GameData;
|
||||
* registering items/blocks inside Compat classes (as the active mod at that
|
||||
* time is always ttCore).
|
||||
*/
|
||||
@UtilityClass
|
||||
public class EnderRegistryUtils {
|
||||
private Method getMain;
|
||||
private Method registerItem;
|
||||
private Method registerBlock;
|
||||
private static Method getMain;
|
||||
private static Method registerItem;
|
||||
private static Method registerBlock;
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -56,9 +54,12 @@ public class EnderRegistryUtils {
|
||||
* @param name
|
||||
* The name of the item
|
||||
*/
|
||||
@SneakyThrows
|
||||
public void registerItem(Item item, String modid, String name) {
|
||||
registerItem.invoke(getMain.invoke(null), item, modid + ":" + name, -1);
|
||||
public static void registerItem(Item item, String modid, String name) {
|
||||
try {
|
||||
registerItem.invoke(getMain.invoke(null), item, modid + ":" + name, -1);
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +74,7 @@ public class EnderRegistryUtils {
|
||||
* @param name
|
||||
* The name of the block
|
||||
*/
|
||||
public void registerBlock(Block block, String modid, String name) {
|
||||
public static void registerBlock(Block block, String modid, String name) {
|
||||
registerBlock(block, null, modid, name);
|
||||
}
|
||||
|
||||
@@ -93,13 +94,9 @@ public class EnderRegistryUtils {
|
||||
* @param itemCtorArgs
|
||||
* Objects to pass as arguments to the ItemBlock.
|
||||
*/
|
||||
@SneakyThrows
|
||||
public void registerBlock(Block block, Class<? extends ItemBlock> itemclass, String modid, String name, Object... itemCtorArgs) {
|
||||
public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass, String modid, String name, Object... itemCtorArgs) {
|
||||
if (Loader.instance().isInState(LoaderState.CONSTRUCTING)) {
|
||||
FMLLog
|
||||
.warning(
|
||||
"The mod %s is attempting to register a block whilst it it being constructed. This is bad modding practice - please use a proper mod lifecycle event.",
|
||||
Loader.instance().activeModContainer());
|
||||
FMLLog.warning("The mod %s is attempting to register a block whilst it it being constructed. This is bad modding practice - please use a proper mod lifecycle event.", Loader.instance().activeModContainer());
|
||||
}
|
||||
try {
|
||||
assert block != null : "registerBlock: block cannot be null";
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.enderio.core.common.util;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import com.enderio.core.EnderCore;
|
||||
|
||||
@UtilityClass
|
||||
public class EnderStringUtils {
|
||||
/**
|
||||
* Formats a string and number for use in GUIs and tooltips
|
||||
@@ -23,7 +21,7 @@ public class EnderStringUtils {
|
||||
* - Whether or not to format the thousands
|
||||
* @return A string numeric formatted to use SI suffixes
|
||||
*/
|
||||
public String formatString(String prefix, String suffix, long amnt, boolean useDecimals, boolean formatK) {
|
||||
public static String formatString(String prefix, String suffix, long amnt, boolean useDecimals, boolean formatK) {
|
||||
if (formatK && Long.toString(amnt).length() < 7 && Long.toString(amnt).length() > 3) {
|
||||
return formatSmallerNumber(prefix, suffix, amnt, useDecimals);
|
||||
}
|
||||
@@ -69,11 +67,11 @@ public class EnderStringUtils {
|
||||
* - Whether or not to use decimals in the representation
|
||||
* @return A string numeric formatted to use SI suffixes
|
||||
*/
|
||||
public String formatString(String prefix, String suffix, long amnt, boolean useDecimals) {
|
||||
public static String formatString(String prefix, String suffix, long amnt, boolean useDecimals) {
|
||||
return formatString(prefix, suffix, amnt, useDecimals, false);
|
||||
}
|
||||
|
||||
private String formatSmallerNumber(String prefix, String suffix, long amnt, boolean useDecimals) {
|
||||
private static String formatSmallerNumber(String prefix, String suffix, long amnt, boolean useDecimals) {
|
||||
switch (Long.toString(amnt).length()) {
|
||||
case 4:
|
||||
prefix += Long.toString(amnt).substring(0, 1) + (useDecimals ? "." + Long.toString(amnt).substring(1, 3) : "") + "K" + suffix;
|
||||
@@ -100,7 +98,7 @@ public class EnderStringUtils {
|
||||
* if 10% {@literal <} num {@literal <}= 25% of max: GOLD (orange-ish)<br>
|
||||
* if num {@literal >} 25% of max: GREEN
|
||||
*/
|
||||
public EnumChatFormatting getColorFor(double num, double max) {
|
||||
public static EnumChatFormatting getColorFor(double num, double max) {
|
||||
if (num / max <= .1)
|
||||
return EnumChatFormatting.RED;
|
||||
else if (num / max <= .25)
|
||||
@@ -109,7 +107,7 @@ public class EnderStringUtils {
|
||||
return EnumChatFormatting.GREEN;
|
||||
}
|
||||
|
||||
public String getEffectNameWithLevel(PotionEffect effect) {
|
||||
public static String getEffectNameWithLevel(PotionEffect effect) {
|
||||
String name = EnderCore.lang.localize(effect.getEffectName(), false);
|
||||
|
||||
if (effect.getAmplifier() > 0) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.enderio.core.common.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
@@ -13,10 +13,13 @@ public class PermanentCache<I> extends WorldCache<I> {
|
||||
|
||||
private static final List<PermanentCache<?>> allCaches = Lists.newArrayList();
|
||||
|
||||
@SneakyThrows
|
||||
public PermanentCache(String ident) {
|
||||
super(ident);
|
||||
loadData(getSaveFile());
|
||||
try {
|
||||
loadData(getSaveFile());
|
||||
} catch (IOException e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,7 +52,11 @@ public class PermanentCache<I> extends WorldCache<I> {
|
||||
|
||||
public static void saveCaches() {
|
||||
for (PermanentCache<?> c : allCaches) {
|
||||
c.saveData(c.getSaveFile());
|
||||
try {
|
||||
c.saveData(c.getSaveFile());
|
||||
} catch (IOException e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.enderio.core.common.util;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLStateEvent;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum RegisterTime {
|
||||
PREINIT(FMLPreInitializationEvent.class),
|
||||
INIT(FMLInitializationEvent.class),
|
||||
@@ -14,6 +12,10 @@ public enum RegisterTime {
|
||||
|
||||
private Class<? extends FMLStateEvent> clazz;
|
||||
|
||||
private RegisterTime(Class<? extends FMLStateEvent> clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public static RegisterTime timeFor(FMLStateEvent event) {
|
||||
for (RegisterTime time : values()) {
|
||||
if (time.clazz == event.getClass()) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.FileResourcePack;
|
||||
import net.minecraft.client.resources.IResourcePack;
|
||||
@@ -36,10 +35,14 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
* Also, {@link #setHasPackPng(Class)} allows your resource pack to have a logo.
|
||||
*/
|
||||
public class ResourcePackAssembler {
|
||||
@AllArgsConstructor
|
||||
private class CustomFile {
|
||||
private String ext;
|
||||
private File file;
|
||||
|
||||
private CustomFile(String ext, File file) {
|
||||
this.ext = ext;
|
||||
this.file = file;
|
||||
}
|
||||
}
|
||||
|
||||
private List<File> icons = new ArrayList<File>();
|
||||
|
||||
@@ -4,8 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import com.enderio.core.EnderCore;
|
||||
import com.enderio.core.common.Handlers.Handler;
|
||||
import com.enderio.core.common.Handlers.Handler.Inst;
|
||||
@@ -23,12 +21,18 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
*/
|
||||
@Handler(getInstFrom = Inst.METHOD)
|
||||
public class Scheduler {
|
||||
@AllArgsConstructor
|
||||
|
||||
private static final class Task {
|
||||
private int delay;
|
||||
private Runnable toRun;
|
||||
private Side side;
|
||||
|
||||
private Task(int delay, Runnable toRun, Side side) {
|
||||
this.delay = delay;
|
||||
this.toRun = toRun;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
private boolean run() {
|
||||
if (delay <= 0) {
|
||||
toRun.run();
|
||||
|
||||
@@ -4,12 +4,12 @@ import gnu.trove.map.TIntObjectMap;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.BitSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -20,6 +20,7 @@ import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -58,21 +59,27 @@ public class WorldCache<I> {
|
||||
@SubscribeEvent
|
||||
public void onWorldSave(WorldEvent.Save event) {
|
||||
if (!event.world.isRemote && event.world.provider.dimensionId == 0) {
|
||||
saveData(getSaveFile());
|
||||
try {
|
||||
saveData(getSaveFile());
|
||||
} catch (IOException e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SneakyThrows
|
||||
public void onWorldLoad(WorldEvent.Load event) {
|
||||
if (!event.world.isRemote && event.world.provider.dimensionId == 0) {
|
||||
loadData(getSaveFile());
|
||||
try {
|
||||
loadData(getSaveFile());
|
||||
} catch (IOException e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
locked = true;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected void loadData(File file) {
|
||||
protected void loadData(File file) throws IOException {
|
||||
if (!file.createNewFile()) {
|
||||
NBTTagCompound tag = null;
|
||||
try {
|
||||
@@ -107,8 +114,7 @@ public class WorldCache<I> {
|
||||
generateIDs();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected void saveData(File file) {
|
||||
protected void saveData(File file) throws IOException {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
// name <-> id mappings
|
||||
@@ -179,7 +185,6 @@ public class WorldCache<I> {
|
||||
usedIDs.set(id, true);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected File getSaveFile() {
|
||||
return new File(DimensionManager.getCurrentSaveRootDirectory(), ident + ".json");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user