mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-27 15:23:03 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
6b208b98bc
commit
a309488cdf
214 files changed
+9283
-9265
No files matched your search
@@ -1,18 +1,15 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||
* Tools | Templates and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.mc1710.game;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.block.IBlockDefinition;
|
||||
@@ -23,13 +20,12 @@ import minetweaker.api.item.IItemDefinition;
|
||||
import minetweaker.api.liquid.ILiquidDefinition;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.api.world.IBiome;
|
||||
// TODO Find this
|
||||
// import GuiCannotRemodify;
|
||||
import minetweaker.mc1710.entity.MCEntityDefinition;
|
||||
import minetweaker.mc1710.item.MCItemDefinition;
|
||||
import minetweaker.mc1710.liquid.MCLiquidDefinition;
|
||||
import minetweaker.mc1710.util.MineTweakerHacks;
|
||||
import minetweaker.mc1710.util.MineTweakerPlatformUtils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -37,212 +33,213 @@ import net.minecraft.util.*;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MCGame implements IGame {
|
||||
private static final Map<String, String> TRANSLATIONS = MineTweakerHacks.getTranslations();
|
||||
|
||||
public static final MCGame INSTANCE = new MCGame();
|
||||
private static final Map<String, String> TRANSLATIONS = MineTweakerHacks.getTranslations();
|
||||
|
||||
private boolean locked = false;
|
||||
public static final MCGame INSTANCE = new MCGame();
|
||||
|
||||
private boolean locked = false;
|
||||
private static final List<IEntityDefinition> ENTITY_DEFINITIONS = new ArrayList<IEntityDefinition>();
|
||||
|
||||
private MCGame() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IItemDefinition> getItems() {
|
||||
List<IItemDefinition> result = new ArrayList<IItemDefinition>();
|
||||
for (String item : (Set<String>) Item.itemRegistry.getKeys()) {
|
||||
result.add(new MCItemDefinition(item, (Item) Item.itemRegistry.getObject(item)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private MCGame() {}
|
||||
|
||||
@Override
|
||||
public List<IBlockDefinition> getBlocks() {
|
||||
List<IBlockDefinition> result = new ArrayList<IBlockDefinition>();
|
||||
for (String block : (Set<String>) Block.blockRegistry.getKeys()) {
|
||||
result.add(MineTweakerMC.getBlockDefinition((Block) Block.blockRegistry.getObject(block)));
|
||||
}
|
||||
@Override
|
||||
public List<IItemDefinition> getItems() {
|
||||
List<IItemDefinition> result = new ArrayList<IItemDefinition>();
|
||||
for (String item : (Set<String>) Item.itemRegistry.getKeys()) {
|
||||
result.add(new MCItemDefinition(item, (Item) Item.itemRegistry.getObject(item)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public List<IBlockDefinition> getBlocks() {
|
||||
List<IBlockDefinition> result = new ArrayList<IBlockDefinition>();
|
||||
for (String block : (Set<String>) Block.blockRegistry.getKeys()) {
|
||||
result.add(MineTweakerMC.getBlockDefinition((Block) Block.blockRegistry.getObject(block)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidDefinition> getLiquids() {
|
||||
List<ILiquidDefinition> result = new ArrayList<ILiquidDefinition>();
|
||||
for (Map.Entry<String, Fluid> entry : FluidRegistry.getRegisteredFluids().entrySet()) {
|
||||
result.add(new MCLiquidDefinition(entry.getValue()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidDefinition> getLiquids() {
|
||||
List<ILiquidDefinition> result = new ArrayList<ILiquidDefinition>();
|
||||
for (Map.Entry<String, Fluid> entry : FluidRegistry.getRegisteredFluids().entrySet()) {
|
||||
result.add(new MCLiquidDefinition(entry.getValue()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IBiome> getBiomes() {
|
||||
List<IBiome> result = new ArrayList<IBiome>();
|
||||
for (IBiome biome : MineTweakerMC.biomes) {
|
||||
if (biome != null) {
|
||||
result.add(biome);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IBiome> getBiomes() {
|
||||
List<IBiome> result = new ArrayList<IBiome>();
|
||||
for (IBiome biome : MineTweakerMC.biomes) {
|
||||
if (biome != null) {
|
||||
result.add(biome);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IEntityDefinition> getEntities() {
|
||||
final Set<EntityRegistry.EntityRegistration> values = MineTweakerHacks.getEntityClassRegistrations().values();
|
||||
if(Iterables.size(values) != ENTITY_DEFINITIONS.size()) {
|
||||
if (Iterables.size(values) != ENTITY_DEFINITIONS.size()) {
|
||||
ENTITY_DEFINITIONS.clear();
|
||||
for(EntityRegistry.EntityRegistration entry : values) {
|
||||
for (EntityRegistry.EntityRegistration entry : values) {
|
||||
ENTITY_DEFINITIONS.add(new MCEntityDefinition(entry));
|
||||
}
|
||||
}
|
||||
return ENTITY_DEFINITIONS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IEntityDefinition getEntity(String entityName) {
|
||||
for(IEntityDefinition ent : getEntities()) {
|
||||
if(ent.getName().equalsIgnoreCase(entityName)) {
|
||||
for (IEntityDefinition ent : getEntities()) {
|
||||
if (ent.getName().equalsIgnoreCase(entityName)) {
|
||||
return ent;
|
||||
}
|
||||
}
|
||||
boolean needsReloading = false;
|
||||
for(EntityRegistry.EntityRegistration res : MineTweakerHacks.getEntityClassRegistrations().values()) {
|
||||
if(res.getEntityName().equalsIgnoreCase(entityName)) {
|
||||
for (EntityRegistry.EntityRegistration res : MineTweakerHacks.getEntityClassRegistrations().values()) {
|
||||
if (res.getEntityName().equalsIgnoreCase(entityName)) {
|
||||
needsReloading = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(needsReloading) {
|
||||
if (needsReloading) {
|
||||
ENTITY_DEFINITIONS.clear();
|
||||
for(EntityRegistry.EntityRegistration entry : MineTweakerHacks.getEntityClassRegistrations().values()) {
|
||||
for (EntityRegistry.EntityRegistration entry : MineTweakerHacks.getEntityClassRegistrations().values()) {
|
||||
ENTITY_DEFINITIONS.add(new MCEntityDefinition(entry));
|
||||
}
|
||||
}
|
||||
|
||||
for(IEntityDefinition entity : getEntities()) {
|
||||
if(entity.getName().equalsIgnoreCase(entityName)) {
|
||||
|
||||
for (IEntityDefinition entity : getEntities()) {
|
||||
if (entity.getName().equalsIgnoreCase(entityName)) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setLocalization(String key, String value) {
|
||||
MineTweakerAPI.apply(new SetTranslation(null, key, value));
|
||||
}
|
||||
public void setLocalization(String key, String value) {
|
||||
MineTweakerAPI.apply(new SetTranslation(null, key, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocalization(String lang, String key, String value) {
|
||||
MineTweakerAPI.apply(new SetTranslation(lang, key, value));
|
||||
}
|
||||
@Override
|
||||
public void setLocalization(String lang, String key, String value) {
|
||||
MineTweakerAPI.apply(new SetTranslation(lang, key, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String localize(String key) {
|
||||
return LanguageRegistry.instance().getStringLocalization(key);
|
||||
}
|
||||
@Override
|
||||
public String localize(String key) {
|
||||
return LanguageRegistry.instance().getStringLocalization(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String localize(String key, String lang) {
|
||||
return LanguageRegistry.instance().getStringLocalization(key, lang);
|
||||
}
|
||||
@Override
|
||||
public String localize(String key, String lang) {
|
||||
return LanguageRegistry.instance().getStringLocalization(key, lang);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lock()
|
||||
{
|
||||
locked = true;
|
||||
}
|
||||
@Override
|
||||
public void lock() {
|
||||
locked = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked()
|
||||
{
|
||||
return locked;
|
||||
}
|
||||
@Override
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void signalLockError()
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Reload of scripts blocked (script lock)");
|
||||
@Override
|
||||
public void signalLockError() {
|
||||
MineTweakerAPI.getLogger().logError("Reload of scripts blocked (script lock)");
|
||||
|
||||
if (Minecraft.isGuiEnabled()) {
|
||||
// Commented out due to unresolved import
|
||||
/**
|
||||
* Minecraft.getMinecraft().displayGuiScreen( new GuiCannotRemodify(
|
||||
* "Minecraft has been tweaked for another server",
|
||||
* "with modifications that cannot be rolled back.",
|
||||
* "Please restart your game."));
|
||||
**/
|
||||
}
|
||||
}
|
||||
if (Minecraft.isGuiEnabled()) {
|
||||
// Commented out due to unresolved import
|
||||
/**
|
||||
* Minecraft.getMinecraft().displayGuiScreen( new GuiCannotRemodify( "Minecraft has been tweaked for another
|
||||
* server", "with modifications that cannot be rolled back.", "Please restart your game."));
|
||||
**/
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
/**
|
||||
* Ported from ModTweaker.
|
||||
*
|
||||
* @author Joshiejack
|
||||
*/
|
||||
private static class SetTranslation implements IUndoableAction {
|
||||
private String original;
|
||||
private final String lang;
|
||||
private final String key;
|
||||
private final String text;
|
||||
private boolean added;
|
||||
/**
|
||||
* Ported from ModTweaker.
|
||||
*
|
||||
* @author Joshiejack
|
||||
*/
|
||||
private static class SetTranslation implements IUndoableAction {
|
||||
|
||||
public SetTranslation(String lang, String key, String text) {
|
||||
this.lang = lang;
|
||||
this.key = key;
|
||||
this.text = text;
|
||||
}
|
||||
private String original;
|
||||
private final String lang;
|
||||
private final String key;
|
||||
private final String text;
|
||||
private boolean added;
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (lang == null || MineTweakerPlatformUtils.isLanguageActive(lang)) {
|
||||
original = TRANSLATIONS.get(key);
|
||||
TRANSLATIONS.put(key, text);
|
||||
added = true;
|
||||
} else {
|
||||
added = false;
|
||||
}
|
||||
}
|
||||
public SetTranslation(String lang, String key, String text) {
|
||||
this.lang = lang;
|
||||
this.key = key;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return TRANSLATIONS != null;
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
if (lang == null || MineTweakerPlatformUtils.isLanguageActive(lang)) {
|
||||
original = TRANSLATIONS.get(key);
|
||||
TRANSLATIONS.put(key, text);
|
||||
added = true;
|
||||
} else {
|
||||
added = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if (added) {
|
||||
if (original == null) {
|
||||
TRANSLATIONS.remove(key);
|
||||
} else {
|
||||
TRANSLATIONS.put(key, original);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return TRANSLATIONS != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Setting localization for the key: " + key + " to " + text;
|
||||
}
|
||||
@Override
|
||||
public void undo() {
|
||||
if (added) {
|
||||
if (original == null) {
|
||||
TRANSLATIONS.remove(key);
|
||||
} else {
|
||||
TRANSLATIONS.put(key, original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Setting localization for the key: " + key + " to " + original;
|
||||
}
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Setting localization for the key: " + key + " to " + text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Setting localization for the key: " + key + " to " + original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user