Skip to content

Commit 717831e

Browse files
committed
Add texture
1 parent 06584f0 commit 717831e

File tree

10 files changed

+44
-24
lines changed

10 files changed

+44
-24
lines changed

src/main/java/ru/lionzxy/fastlogblock/FastLogBlock.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package ru.lionzxy.fastlogblock;
22

3+
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
34
import net.minecraft.item.Item;
5+
import net.minecraftforge.client.model.ModelLoader;
46
import net.minecraftforge.common.MinecraftForge;
57
import net.minecraftforge.event.RegistryEvent;
68
import net.minecraftforge.fml.common.FMLLog;
@@ -34,6 +36,7 @@ public void preInit(FMLPreInitializationEvent event) throws IOException {
3436
@SubscribeEvent
3537
public void registerItems(RegistryEvent.Register<Item> event) {
3638
event.getRegistry().registerAll(infoitem);
39+
ModelLoader.setCustomModelResourceLocation(infoitem, 0, new ModelResourceLocation(infoitem.getRegistryName(), "inventory"));
3740
}
3841

3942
@EventHandler

src/main/java/ru/lionzxy/fastlogblock/config/LogConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
@Config(modid = FastLogBlock.MODID)
1313
@Config.LangKey("fastlogblock.config.title")
1414
public class LogConfig {
15+
@Config.Comment("Enable handling event")
16+
public static boolean loggingEnable = true;
1517
@Config.Comment("Filepath from minecraft root folder to block log path")
1618
public static String logFolderPath = "blocklog";
1719
@Config.Comment("Path to nickname mapper file from logFolderPath")
@@ -27,6 +29,8 @@ public class LogConfig {
2729
public static int writeWorkersCount = 4;
2830
@Config.Comment("Regular expression for block change event ignore")
2931
public static String[] ignoreBlockNamesRegExp = new String[]{"<minecraft:tallgrass:*>"};
32+
@Config.Comment("Permission level for show block log.")
33+
public static boolean onlyForOP = true;
3034

3135
public static class HashConfig {
3236
@Config.Comment("Max logfile count")

src/main/java/ru/lionzxy/fastlogblock/handlers/EventHandlingManager.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.minecraftforge.fml.common.FMLLog;
1010
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
1111
import net.minecraftforge.fml.common.gameevent.TickEvent;
12+
import ru.lionzxy.fastlogblock.config.LogConfig;
1213
import ru.lionzxy.fastlogblock.io.ReadRunnable;
1314
import ru.lionzxy.fastlogblock.models.BlockChangeEventModel;
1415
import ru.lionzxy.fastlogblock.models.BlockChangeEventModelWithWorld;
@@ -40,26 +41,12 @@ public EventHandlingManager() throws IOException {
4041

4142
@SubscribeEvent
4243
public void onBlockBreak(final BlockEvent.BreakEvent event) {
43-
final BlockChangeEventModelWithWorld blockChangeEventModel = (BlockChangeEventModelWithWorld) BlockChangeEventModel.getChangeEvent(event);
44-
45-
if (blockChangeEventModel == null) {
46-
return;
47-
}
48-
49-
FMLLog.log.debug(blockChangeEventModel.toString());
50-
splitterRunnable.addEvent(blockChangeEventModel);
44+
logEvent((BlockChangeEventModelWithWorld) BlockChangeEventModel.getChangeEvent(event), event);
5145
}
5246

5347
@SubscribeEvent
5448
public void onBlockPlace(final BlockEvent.PlaceEvent event) {
55-
final BlockChangeEventModelWithWorld blockChangeEventModel = (BlockChangeEventModelWithWorld) BlockChangeEventModel.getChangeEvent(event);
56-
57-
if (blockChangeEventModel == null) {
58-
return;
59-
}
60-
61-
FMLLog.log.debug(blockChangeEventModel.toString());
62-
splitterRunnable.addEvent(blockChangeEventModel);
49+
logEvent((BlockChangeEventModelWithWorld) BlockChangeEventModel.getChangeEvent(event), event);
6350
}
6451

6552
@SubscribeEvent
@@ -119,4 +106,18 @@ private void notifyAboutEvent(BlockChangeEventModel blockEvent, EntityPlayer ent
119106
}
120107
entityPlayer.sendMessage(textComponent);
121108
}
109+
110+
111+
private void logEvent(BlockChangeEventModelWithWorld changeEvent, BlockEvent event) {
112+
if (!LogConfig.loggingEnable) {
113+
return;
114+
}
115+
116+
if (changeEvent == null) {
117+
return;
118+
}
119+
120+
FMLLog.log.debug(changeEvent.toString());
121+
splitterRunnable.addEvent(changeEvent);
122+
}
122123
}

src/main/java/ru/lionzxy/fastlogblock/models/ASCIString.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.nio.charset.Charset;
44

55
public class ASCIString implements CharSequence {
6-
private final static Charset asci = Charset.forName("ASCII");
6+
private final static Charset ASCI = Charset.forName("ASCII");
77
private final byte[] shortString;
88
private int hashcode = -1;
99

@@ -14,7 +14,7 @@ public ASCIString(final byte[] fatString) {
1414
}
1515

1616
public ASCIString(final String fatString) {
17-
shortString = fatString.getBytes(asci);
17+
shortString = fatString.getBytes(ASCI);
1818

1919
initHash();
2020
}
@@ -31,7 +31,7 @@ public char charAt(final int index) {
3131

3232
@Override
3333
public CharSequence subSequence(final int start, final int end) {
34-
return new String(shortString, asci).subSequence(start, end);
34+
return new String(shortString, ASCI).subSequence(start, end);
3535
}
3636

3737
@Override
@@ -61,7 +61,7 @@ public boolean equals(final Object obj) {
6161

6262
@Override
6363
public String toString() {
64-
return new String(shortString, asci);
64+
return new String(shortString, ASCI);
6565
}
6666

6767
public byte[] getShortString() {

src/main/java/ru/lionzxy/fastlogblock/ui/InfoItem.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.minecraft.world.World;
1313
import ru.lionzxy.fastlogblock.FastLogBlock;
1414
import ru.lionzxy.fastlogblock.handlers.EventHandlingManager;
15+
import ru.lionzxy.fastlogblock.utils.MinecraftUtils;
1516

1617
import java.util.Objects;
1718

@@ -33,6 +34,10 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p
3334
if (worldIn.isRemote) {
3435
return EnumActionResult.FAIL;
3536
}
37+
if (!MinecraftUtils.canShowLog(player)) {
38+
player.sendMessage(new TextComponentTranslation("message.fastlogblock:blockinfo.event.permissionerror"));
39+
return EnumActionResult.FAIL;
40+
}
3641
player.sendMessage(new TextComponentTranslation("message.fastlogblock:blockinfo.start", pos.getX(), pos.getY(), pos.getZ()));
3742
eventHandlingManager.handleLogByPos(player, pos, worldIn);
3843
return EnumActionResult.SUCCESS;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package ru.lionzxy.fastlogblock.utils;
22

33
import net.minecraft.entity.player.EntityPlayer;
4+
import ru.lionzxy.fastlogblock.config.LogConfig;
45

56
public class MinecraftUtils {
6-
public static boolean isOp(EntityPlayer player) {
7-
player.getEntityWorld().getMinecraftServer();
8-
return false;
7+
public static boolean canShowLog(EntityPlayer player) {
8+
return !LogConfig.onlyForOP || player.getEntityWorld().getMinecraftServer().isSinglePlayer() || player.canUseCommand(player.getEntityWorld().getMinecraftServer().getOpPermissionLevel(), "");
99
}
1010
}

src/main/resources/assets/fastlogblock/lang/en_us.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ message.fastlogblock:blockinfo.event.insert=§2[+]§6[%s§6]§f %s: %s
33
message.fastlogblock:blockinfo.event.remove=§4[-]§6[%s§6]§f %s: %s
44
message.fastlogblock:blockinfo.event.done=§3[FastLogBlock]§f Done!
55
message.fastlogblock:blockinfo.event.empty=§3[FastLogBlock]§f Not found changes with block
6+
message.fastlogblock:blockinfo.event.permissionerror=§3[FastLogBlock]§4 Permission error. You can't use this mod (with current settings this mod can use only Server Admin)
67
message.fastlogblock:blockinfo.event.dateformat=dd/MM/yyyy HH:mm:ss
78

89
item.fastlogblock:infoitem.name=FastBlockLog Info Item
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "item/generated",
3+
"textures": {
4+
"layer0": "fastlogblock:items/infoitem"
5+
}
6+
}
708 Bytes
Loading

src/main/resources/mcmod.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "",
99
"updateUrl": "",
1010
"authorList": [
11-
"LionZXYY"
11+
"LionZXY"
1212
],
1313
"credits": "The Forge and FML guys, for making Forge ;)",
1414
"logoFile": "",

0 commit comments

Comments
 (0)