Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
v1.3 Update to add new language inject event
  • Loading branch information
dries007 committed Aug 18, 2016
1 parent 55621b9 commit 221a6f0
Show file tree
Hide file tree
Showing 9 changed files with 314 additions and 27 deletions.
17 changes: 12 additions & 5 deletions build.gradle
Expand Up @@ -30,7 +30,7 @@ apply plugin: "idea-utils"
apply plugin: "maven"

group = "net.doubledoordev.d3core"
version = "1.2.1"
version = "1.3.0"

targetCompatibility = 1.7
sourceCompatibility = 1.7
Expand Down Expand Up @@ -88,7 +88,9 @@ task deobfJar(type: Jar, dependsOn: 'jar') {
classifier "dev"
appendix = project.minecraft.version
manifest {
attributes 'FMLAT': 'D3Core_at.cfg'
attributes 'FMLAT': 'D3Core_at.cfg',
// 'FMLCorePluginContainsFMLMod': 'true',
// 'FMLCorePlugin': 'net.doubledoordev.d3core.asm.D3CoreMod'
}
}
sourceJar {
Expand All @@ -97,7 +99,9 @@ sourceJar {
classifier "src"
appendix = project.minecraft.version
manifest {
attributes 'FMLAT': 'D3Core_at.cfg'
attributes 'FMLAT': 'D3Core_at.cfg',
// 'FMLCorePluginContainsFMLMod': 'true',
// 'FMLCorePlugin': 'net.doubledoordev.d3core.asm.D3CoreMod'
}
}
//noinspection GroovyAssignabilityCheck
Expand All @@ -106,7 +110,10 @@ jar {
exclude("com/**")
appendix = project.minecraft.version
manifest {
attributes 'FMLAT': 'D3Core_at.cfg'
attributes 'FMLAT': 'D3Core_at.cfg',
// 'FMLCorePluginContainsFMLMod': 'true',
// 'FMLCorePlugin': 'net.doubledoordev.d3core.asm.D3CoreMod'

}
}
artifacts {
Expand Down Expand Up @@ -176,4 +183,4 @@ uploadArchives {
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/net/doubledoordev/d3core/D3Core.java
Expand Up @@ -33,7 +33,6 @@

import net.doubledoordev.d3core.client.LanguageHelper;
import net.doubledoordev.d3core.util.*;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
Expand Down Expand Up @@ -86,6 +85,7 @@ public void preInit(FMLPreInitializationEvent event)
logger = event.getModLog();

MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(LanguageHelper.I);
MinecraftForge.EVENT_BUS.register(EventHandler.I);
MinecraftForge.EVENT_BUS.register(VOID_REFUNDS);

Expand Down Expand Up @@ -150,6 +150,7 @@ private void updateConfig()
EventHandler.I.nosleep = configuration.getBoolean("nosleep", MODID, EventHandler.I.nosleep, "No sleep at all", "d3.core.config.nosleep");
EventHandler.I.printDeathCoords = configuration.getBoolean("printDeathCoords", MODID, EventHandler.I.printDeathCoords, "Print your death coordinates in chat (client side)", "d3.core.config.printDeathCoords");
EventHandler.I.claysTortureMode = configuration.getBoolean("claysTortureMode", MODID, EventHandler.I.claysTortureMode, "Deletes all drops on death.", "d3.core.config.claystorturemode");
// EventHandler.I.lagMitigation = configuration.getBoolean("lagMitigation", MODID, EventHandler.I.lagMitigation, "Based on server TPS make not all entities tick every server tick.", "d3.core.config.lagmitigation");
aprilFools = configuration.getBoolean("aprilFools", MODID, aprilFools, "What would this do...");
getDevPerks().update(silliness);

Expand Down
54 changes: 33 additions & 21 deletions src/main/java/net/doubledoordev/d3core/client/LanguageHelper.java
Expand Up @@ -31,8 +31,8 @@

package net.doubledoordev.d3core.client;

import net.doubledoordev.d3core.events.D3LanguageInjectEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
Expand All @@ -41,6 +41,8 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.translation.LanguageMap;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -56,7 +58,10 @@
public class LanguageHelper
{
private final static LinkedHashMap<String, Integer> ROMAN_NUMERALS = new LinkedHashMap<>();
static {
public static final LanguageHelper I = new LanguageHelper();

static
{
ROMAN_NUMERALS.put("M", 1000);
ROMAN_NUMERALS.put("CM", 900);
ROMAN_NUMERALS.put("D", 500);
Expand All @@ -81,25 +86,9 @@ public static void run()
@Override
public void onResourceManagerReload(IResourceManager resourceManager)
{
Enchantment enchantment = null;
//noinspection StatementWithEmptyBody
for (int i = 0; enchantment == null; enchantment = Enchantment.REGISTRY.getObjectById(i++));
Item item = null;
//noinspection StatementWithEmptyBody
for (int i = 0; item == null; item = Item.REGISTRY.getObjectById(i++));
ItemStack s = new ItemStack(item);
s.addEnchantment(enchantment, Integer.MAX_VALUE);
final int max = EnchantmentHelper.getEnchantmentLevel(enchantment, s);
for (int i = 0; i < max; i++)
{
String key = PREFIX + i;
if (!I18n.i18nLocale.properties.containsKey(key))
{
String val = romanNumerals(i);
I18n.i18nLocale.properties.put(key, val);
}
}
LanguageMap.replaceWith(I18n.i18nLocale.properties);
D3LanguageInjectEvent event = new D3LanguageInjectEvent();
MinecraftForge.EVENT_BUS.post(event);
LanguageMap.replaceWith(event.map);
}
});
}
Expand All @@ -120,4 +109,27 @@ private static String romanNumerals(int Int)
}
return builder.toString();
}

@SubscribeEvent
public void d3LanguageInjectEvent(D3LanguageInjectEvent event)
{
Enchantment enchantment = null;
//noinspection StatementWithEmptyBody
for (int i = 0; enchantment == null; enchantment = Enchantment.REGISTRY.getObjectById(i++));
Item item = null;
//noinspection StatementWithEmptyBody
for (int i = 0; item == null; item = Item.REGISTRY.getObjectById(i++));
ItemStack s = new ItemStack(item);
s.addEnchantment(enchantment, Integer.MAX_VALUE);
final int max = EnchantmentHelper.getEnchantmentLevel(enchantment, s);
for (int i = 0; i < max; i++)
{
String key = PREFIX + i;
if (!event.map.containsKey(key))
{
String val = romanNumerals(i);
event.map.put(key, val);
}
}
}
}
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2014-2016, Dries007 & DoubleDoorDevelopment
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of DoubleDoorDevelopment nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/

package net.doubledoordev.d3core.events;

import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.common.eventhandler.Event;

import java.util.Map;

public class D3LanguageInjectEvent extends Event
{
public final Map<String, String> map;

public D3LanguageInjectEvent()
{
this.map = I18n.i18nLocale.properties;
}
}
43 changes: 43 additions & 0 deletions src/main/java/net/doubledoordev/d3core/util/EventHandler.java
Expand Up @@ -77,6 +77,7 @@
public class EventHandler
{
public static final EventHandler I = new EventHandler();
// public boolean lagMitigation;
public boolean enableStringID;
public boolean enableUnlocalizedName;
public boolean enableOreDictionary;
Expand All @@ -89,8 +90,50 @@ public class EventHandler
public boolean lilypad;
public boolean achievementFireworks;

// private static int tps = 20;

private EventHandler() {}

// private static PrintWriter pw;
//
// static
// {
// try
// {
// File f = new File("ticktimes.csv");
// f.createNewFile();
// pw = new PrintWriter(f);
// }
// catch (IOException e)
// {
// Throwables.propagate(e);
// }
// }

// @SubscribeEvent
// public void serverTickHandler(TickEvent.ServerTickEvent event)
// {
// if (!lagMitigation) return;
// MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
// if (server.getTickCounter() % 100 == 0)
// {
// StringBuilder sb = new StringBuilder().append(server.getTickCounter());
// for (long l : server.tickTimeArray) sb.append(',').append(l);
// sb.append('\n');
// pw.write(sb.toString());
// pw.flush();
// }
// }

// @SubscribeEvent(priority = EventPriority.HIGHEST)
// public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event)
// {
// EntityLivingBase elb = event.getEntityLiving();
// if (elb.worldObj.isRemote || elb instanceof EntityPlayer || !lagMitigation) return;
// if (elb.getControllingPassenger() != null) return;
//// if ((tps <= 15 && elb instanceof EntityAnimal) || (tps <= 12 && elb instanceof EntityMob)) event.setCanceled(true);
// }

@SubscribeEvent(priority = EventPriority.LOWEST)
public void itemTooltipEventHandler(ItemTooltipEvent event)
{
Expand Down
54 changes: 54 additions & 0 deletions src/main/resources/assets/d3core/lang/en_US.lang
@@ -0,0 +1,54 @@
d3.core.config.title=D³ configuration screen

d3.core.config.core=Core config
d3.core.config.core.tooltip=Applies to all D³ mods

d3.core.config.debug=Debug mode
d3.core.config.debug.tooltip=Please enable before making a bug report.

d3.core.config.printDeathCoords=Print your death coordinates in chat (client side)
d3.core.config.printDeathCoords.tooltip=Contains a clickable TP command thing too!

d3.core.config.Silliness=Enable silliness
d3.core.config.Silliness.tooltip=Please don't disable, unless you want to piss off the D³ crew :p But seriously, you can disable name changes, drops and block helmets with this setting.

d3.core.config.achievementFireworks=Achievement is Fireworks!
d3.core.config.achievementFireworks.tooltip=I made this just to annoy Clay & James. Have fun with it!

d3.core.config.tooltips=Tooltips
d3.core.config.tooltips.tooltip=Item hover options, toggle with F3 + H

d3.core.config.tooltips.enableStringID=Enable StringID
d3.core.config.tooltips.enableStringID.tooltip=Example: minecraft:gold_ore

d3.core.config.tooltips.enableUnlocalizedName=Enable Unlocalized Name
d3.core.config.tooltips.enableUnlocalizedName.tooltip=Example: tile.oreGold

d3.core.config.tooltips.enableOreDictionary=Enable OreDictionary
d3.core.config.tooltips.enableOreDictionary.tooltip=Example: oreGold

d3.core.config.EndermanGriefing=Enderman Griefing
d3.core.config.EndermanGriefing.tooltip=Modify Enderman griefing

d3.core.config.EndermanGriefing.disable=Disable
d3.core.config.EndermanGriefing.disable.tooltip=Disable Enderman griefing completely.

d3.core.config.EndermanGriefing.dropCarrying=Drop Carrying
d3.core.config.EndermanGriefing.dropCarrying.tooltip=Made Enderman drop there carrying block on death.

d3.core.config.EndermanGriefing.blacklist=Blacklist
d3.core.config.EndermanGriefing.blacklist.tooltip=List of blocks (minecraft:stone) that will never be allowed to be picked up.

d3.core.config.EndermanGriefing.addlist=Addlist
d3.core.config.EndermanGriefing.addlist.tooltip=List of blocks (minecraft:stone) that will be added to the list of blocks Enderman pick up.

commands.d3group.usage='/d3group help' for help
commands.d3group.help.new=/d3group new <group> [parent group]
commands.d3group.help.remove=/d3group remove <group>
commands.d3group.help.node.add=/d3group node <group> add <permission node>
commands.d3group.help.node.remove=/d3group node <group> remove <permission node>
commands.d3group.help.parent.set=/d3group parent <group> set <parent group>
commands.d3group.help.parent.clear=/d3group parent <group> clear

d3.core.cmd.setloginmessage.success=Set login message!
d3.core.cmd.setloginmessage.removed=Removed login message!
21 changes: 21 additions & 0 deletions src/main/resources/assets/d3core/lang/pl_PL.lang
@@ -0,0 +1,21 @@
d3.core.config.title=Ekran konfiguracji D³

d3.core.config.core=Konfiguracja rdzenia
d3.core.config.core.tooltip=Działa na wszystkie mody D³

d3.core.config.debug=Tryb debugowania
d3.core.config.debug.tooltip=Proszę włączyć przed reportowaniem bugów.

d3.core.config.silliness=Włącz głupoty
d3.core.config.silliness.tooltip=Proszę nie wyłączać, chyba, że chcesz wkurzyć ekipę D³ :p Ale poważnie, możesz wyłączyć zmiany nazw, wypadające przedmioty i blokować hełmy tym ustawieniem.

d3.core.config.updateWarning=Ostrzeżenia o uaktualnieniach
d3.core.config.updateWarning.tooltip=Proszę nie wyłączać, chyba, że używasz paczki modów.

commands.d3group.usage='/d3group help' dla pomocy
commands.d3group.help.new=/d3group new <grupa> [grupa nadrzędna]
commands.d3group.help.remove=/d3group remove <grupa>
commands.d3group.help.node.add=/d3group node <grupa> add <węzeł uprawnień>
commands.d3group.help.node.remove=/d3group node <grupa> remove <węzeł uprawnień>
commands.d3group.help.parent.set=/d3group parent <grupa> set <grupa nadrzędna>
commands.d3group.help.parent.clear=/d3group parent <grupa> clear
48 changes: 48 additions & 0 deletions src/main/resources/assets/d3core/lang/ru_RU.lang
@@ -0,0 +1,48 @@
d3.core.config.title=Конфигурация D³

d3.core.config.core=Главная конфигурация
d3.core.config.core.tooltip=Применяется для всех модов D³

d3.core.config.debug=Режим отладки
d3.core.config.debug.tooltip=Пожалуйста, включите, прежде чем отправить отчёт об ошибке.

d3.core.config.silliness=Включение примочек
d3.core.config.silliness.tooltip=Пожалуйста не отключайте, если Вы не хотите позлить команду D³ :p А если серьезно, Вы можете отключить изменения имени, выпадение предметов и шлемы-блоки этой настройкой.

d3.core.config.updateWarning=Предупреждения об обновлениях
d3.core.config.updateWarning.tooltip=Пожалуйста, не отключайте, если только Вы не используете пакет модов.

d3.core.config.tooltips=Подсказки
d3.core.config.tooltips.tooltip=Подсказки к предметам, переключаются с помощью F3 + H

d3.core.config.tooltips.enableStringID=Включение StringID
d3.core.config.tooltips.enableStringID.tooltip=Пример: minecraft:gold_ore

d3.core.config.tooltips.enableUnlocalizedName=Включение Unlocalized Name
d3.core.config.tooltips.enableUnlocalizedName.tooltip=Пример: tile.oreGold

d3.core.config.tooltips.enableOreDictionary=Включение словаря руд
d3.core.config.tooltips.enableOreDictionary.tooltip=Пример: oreGold

d3.core.config.EndermanGriefing=Взаимодействие странника Края с миром
d3.core.config.EndermanGriefing.tooltip=Изменение взаимодействия странника Края с миром

d3.core.config.EndermanGriefing.disable=Отключить
d3.core.config.EndermanGriefing.disable.tooltip=Полностью отключает взаимодействие странника Края с миром.

d3.core.config.EndermanGriefing.dropCarrying=Бросать блок в руке
d3.core.config.EndermanGriefing.dropCarrying.tooltip=Заставляет странника Края бросить переносимый блок при смерти.

d3.core.config.EndermanGriefing.blacklist=Чёрный список
d3.core.config.EndermanGriefing.blacklist.tooltip=Список блоков (minecraft:stone), которые странник Края не может подбирать.

d3.core.config.EndermanGriefing.addlist=Белый список
d3.core.config.EndermanGriefing.addlist.tooltip=Список блоков (minecraft:stone), которые странник Края сможет подбирать.

commands.d3group.usage='/d3group help' для помощи
commands.d3group.help.new=/d3group new <группа> [исходная группа]
commands.d3group.help.remove=/d3group remove <группа>
commands.d3group.help.node.add=/d3group node <группа> add <узел разрешений>
commands.d3group.help.node.remove=/d3group node <группа> remove <узел разрешений>
commands.d3group.help.parent.set=/d3group parent <группа> set <исходная группа>
commands.d3group.help.parent.clear=/d3group parent <группа> clear

0 comments on commit 221a6f0

Please sign in to comment.