some cleanup

This commit is contained in:
Ellpeck 2017-04-01 19:40:39 +02:00
parent a082fce0a0
commit 13c3df3330
20 changed files with 60 additions and 79 deletions

View file

@ -46,7 +46,7 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.CraftingTweaksCompat; import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
@ -116,8 +116,7 @@ public class ActuallyAdditions{
new CommonEvents(); new CommonEvents();
InitCrafting.init(); InitCrafting.init();
InitEntities.init(); InitEntities.init();
CompatUtil.registerCraftingTweaksCompat();
CraftingTweaksCompat.register();
proxy.init(event); proxy.init(event);
@ -148,7 +147,7 @@ public class ActuallyAdditions{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if(server != null){ if(server != null){
World world = server.getEntityWorld(); World world = server.getEntityWorld();
if(world != null){ if(world != null && !world.isRemote){
WorldData.get(world, true).markDirty(); WorldData.get(world, true).markDirty();
} }
} }

View file

@ -18,11 +18,7 @@ import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom; import de.ellpeck.actuallyadditions.mod.util.*;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;

View file

@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;

View file

@ -101,6 +101,18 @@ public class GuiMainPage extends GuiBooklet{
super(previousScreen, null); super(previousScreen, null);
} }
private static List<IBookletEntry> getDisplayedEntries(){
List<IBookletEntry> displayed = new ArrayList<IBookletEntry>();
for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){
if(entry.visibleOnFrontPage()){
displayed.add(entry);
}
}
return displayed;
}
@Override @Override
public void initGui(){ public void initGui(){
super.initGui(); super.initGui();
@ -290,16 +302,4 @@ public class GuiMainPage extends GuiBooklet{
public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){ public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){
} }
private static List<IBookletEntry> getDisplayedEntries(){
List<IBookletEntry> displayed = new ArrayList<IBookletEntry>();
for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){
if(entry.visibleOnFrontPage()){
displayed.add(entry);
}
}
return displayed;
}
} }

View file

@ -25,11 +25,10 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class PageTrials extends BookletPage{ public class PageTrials extends BookletPage{
private final int buttonId;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private GuiButton button; private GuiButton button;
private final int buttonId;
public PageTrials(int localizationKey, boolean button, boolean text){ public PageTrials(int localizationKey, boolean button, boolean text){
super(localizationKey); super(localizationKey);

View file

@ -105,6 +105,7 @@ public class WorldData extends WorldSavedData{
public static void clear(){ public static void clear(){
if(data != null){ if(data != null){
data = null; data = null;
ModUtil.LOGGER.info("Unloaded WorldData!");
} }
} }

View file

@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage; import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;

View file

@ -10,9 +10,6 @@
package de.ellpeck.actuallyadditions.mod.inventory.gui; package de.ellpeck.actuallyadditions.mod.inventory.gui;
import java.io.IOException;
import java.util.Collections;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerGrinder; import de.ellpeck.actuallyadditions.mod.inventory.ContainerGrinder;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
@ -29,6 +26,9 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import java.io.IOException;
import java.util.Collections;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiGrinder extends GuiContainer{ public class GuiGrinder extends GuiContainer{

View file

@ -44,6 +44,11 @@ public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles{
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
public static boolean isWearing(EntityPlayer player){
ItemStack face = player.inventory.armorInventory.get(3);
return StackUtil.isValid(face) && face.getItem() instanceof IGoggles;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@SubscribeEvent @SubscribeEvent
public void onClientTick(ClientTickEvent event){ public void onClientTick(ClientTickEvent event){
@ -85,11 +90,6 @@ public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles{
} }
} }
public static boolean isWearing(EntityPlayer player){
ItemStack face = player.inventory.armorInventory.get(3);
return StackUtil.isValid(face) && face.getItem() instanceof IGoggles;
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.RARE; return EnumRarity.RARE;

View file

@ -13,8 +13,6 @@ package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage; import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaForgeUnitsWrapper; import de.ellpeck.actuallyadditions.mod.util.compat.TeslaForgeUnitsWrapper;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil; import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;

View file

@ -31,17 +31,6 @@ import java.util.List;
public class DefaultFarmerBehavior implements IFarmerBehavior{ public class DefaultFarmerBehavior implements IFarmerBehavior{
@Override
public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer){
int use = 350;
if(farmer.getEnergy() >= use*2){
if(defaultPlant(world, pos, this.getPlantablePlantFromStack(seed, world, pos), farmer, use)){
return FarmerResult.SUCCESS;
}
}
return FarmerResult.FAIL;
}
public static boolean defaultPlant(World world, BlockPos pos, IBlockState toPlant, IFarmer farmer, int use){ public static boolean defaultPlant(World world, BlockPos pos, IBlockState toPlant, IFarmer farmer, int use){
if(toPlant != null){ if(toPlant != null){
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
@ -86,6 +75,17 @@ public class DefaultFarmerBehavior implements IFarmerBehavior{
return false; return false;
} }
@Override
public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer){
int use = 350;
if(farmer.getEnergy() >= use*2){
if(defaultPlant(world, pos, this.getPlantablePlantFromStack(seed, world, pos), farmer, use)){
return FarmerResult.SUCCESS;
}
}
return FarmerResult.FAIL;
}
@Override @Override
public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer){ public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer){
int use = 250; int use = 250;

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.util.compat; package de.ellpeck.actuallyadditions.mod.util.compat;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCrafter;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops; import net.minecraft.block.BlockCrops;
@ -55,4 +56,11 @@ public final class CompatUtil{
} }
} }
} }
public static void registerCraftingTweaksCompat(){
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setString("ContainerClass", ContainerCrafter.class.getName());
tagCompound.setString("AlignToGrid", "left");
FMLInterModComms.sendMessage("craftingtweaks", "RegisterProvider", tagCompound);
}
} }

View file

@ -1,18 +0,0 @@
package de.ellpeck.actuallyadditions.mod.util.compat;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCrafter;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.common.event.FMLInterModComms;
public class CraftingTweaksCompat{
private static final String MOD_ID = "craftingtweaks";
public static void register(){
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setString("ContainerClass", ContainerCrafter.class.getName());
tagCompound.setString("AlignToGrid", "left");
FMLInterModComms.sendMessage(MOD_ID, "RegisterProvider", tagCompound);
}
}