There we go.

I fixed it.
This commit is contained in:
Ellpeck 2016-02-01 20:39:11 +01:00
parent 228ecd50bd
commit 56489b362a
13 changed files with 124 additions and 120 deletions

View file

@ -31,13 +31,6 @@ public class EntrySet{
this.setEntry(page, chapter, entry, pageInIndex); this.setEntry(page, chapter, entry, pageInIndex);
} }
public void setEntry(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex){
this.page = page;
this.chapter = chapter;
this.entry = entry;
this.pageInIndex = pageInIndex;
}
public static EntrySet readFromNBT(NBTTagCompound compound){ public static EntrySet readFromNBT(NBTTagCompound compound){
if(compound != null){ if(compound != null){
if(compound.hasKey("Entry")){ if(compound.hasKey("Entry")){
@ -56,6 +49,13 @@ public class EntrySet{
return new EntrySet(null); return new EntrySet(null);
} }
public void setEntry(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex){
this.page = page;
this.chapter = chapter;
this.entry = entry;
this.pageInIndex = pageInIndex;
}
public void removeEntry(){ public void removeEntry(){
this.setEntry(null, null, null, 1); this.setEntry(null, null, null, 1);
} }

View file

@ -121,7 +121,9 @@ public class BlockPlant extends BlockCrops{
@Override @Override
public int getDamageValue(World world, BlockPos pos){ public int getDamageValue(World world, BlockPos pos){
return 0; return 0;
} @Override }
@Override
public Item getSeed(){ public Item getSeed(){
return this.seedItem; return this.seedItem;
} }
@ -137,7 +139,6 @@ public class BlockPlant extends BlockCrops{
} }
@Override @Override
public Item getItemDropped(IBlockState state, Random rand, int par3){ public Item getItemDropped(IBlockState state, Random rand, int par3){
return this.getMetaFromState(state) >= 7 ? this.getCrop() : this.getSeed(); return this.getMetaFromState(state) >= 7 ? this.getCrop() : this.getSeed();

View file

@ -28,6 +28,19 @@ import java.util.Locale;
public class PlayerObtainEvents{ public class PlayerObtainEvents{
public static void checkAchievements(ItemStack gotten, EntityPlayer player, InitAchievements.Type type){
for(int i = 0; i < TheAchievements.values().length; i++){
TheAchievements ach = TheAchievements.values()[i];
if(ach.type == type){
if(gotten != null && ach.ach.theItemStack != null && gotten.getItem() == ach.ach.theItemStack.getItem()){
if(gotten.getItemDamage() == ach.ach.theItemStack.getItemDamage()){
player.addStat(ach.ach, 1);
}
}
}
}
}
@SubscribeEvent @SubscribeEvent
public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event){ public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event){
checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING); checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING);
@ -51,19 +64,6 @@ public class PlayerObtainEvents{
} }
} }
public static void checkAchievements(ItemStack gotten, EntityPlayer player, InitAchievements.Type type){
for(int i = 0; i < TheAchievements.values().length; i++){
TheAchievements ach = TheAchievements.values()[i];
if(ach.type == type){
if(gotten != null && ach.ach.theItemStack != null && gotten.getItem() == ach.ach.theItemStack.getItem()){
if(gotten.getItemDamage() == ach.ach.theItemStack.getItemDamage()){
player.addStat(ach.ach, 1);
}
}
}
}
}
@SubscribeEvent @SubscribeEvent
public void onSmeltedEvent(PlayerEvent.ItemSmeltedEvent event){ public void onSmeltedEvent(PlayerEvent.ItemSmeltedEvent event){
checkAchievements(event.smelting, event.player, InitAchievements.Type.SMELTING); checkAchievements(event.smelting, event.player, InitAchievements.Type.SMELTING);

View file

@ -84,6 +84,7 @@ public class GuiGrinder extends GuiContainer{
} }
public static class GuiGrinderDouble extends GuiGrinder{ public static class GuiGrinderDouble extends GuiGrinder{
public GuiGrinderDouble(InventoryPlayer inventory, TileEntityBase tile){ public GuiGrinderDouble(InventoryPlayer inventory, TileEntityBase tile){
super(inventory, tile, true); super(inventory, tile, true);
} }

View file

@ -72,6 +72,15 @@ public class ItemCoffee extends ItemFoodBase{
return null; return null;
} }
public static void applyPotionEffectsFromStack(ItemStack stack, EntityPlayer player){
PotionEffect[] effects = CoffeeBrewing.getEffectsFromStack(stack);
if(effects != null && effects.length > 0){
for(PotionEffect effect : effects){
player.addPotionEffect(new PotionEffect(effect.getPotionID(), effect.getDuration()*20, effect.getAmplifier()));
}
}
}
@Override @Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player){ public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player){
ItemStack theStack = stack.copy(); ItemStack theStack = stack.copy();
@ -86,15 +95,6 @@ public class ItemCoffee extends ItemFoodBase{
} }
} }
public static void applyPotionEffectsFromStack(ItemStack stack, EntityPlayer player){
PotionEffect[] effects = CoffeeBrewing.getEffectsFromStack(stack);
if(effects != null && effects.length > 0){
for(PotionEffect effect : effects){
player.addPotionEffect(new PotionEffect(effect.getPotionID(), effect.getDuration()*20, effect.getAmplifier()));
}
}
}
@Override @Override
public EnumAction getItemUseAction(ItemStack stack){ public EnumAction getItemUseAction(ItemStack stack){
return EnumAction.DRINK; return EnumAction.DRINK;

View file

@ -39,46 +39,6 @@ public class ItemPhantomConnector extends ItemBase{
this.setMaxStackSize(1); this.setMaxStackSize(1);
} }
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing par7, float par8, float par9, float par10){
if(!world.isRemote){
//Passing Data to Phantoms
TileEntity tile = world.getTileEntity(pos);
if(tile != null){
//Passing to Phantom
if(tile instanceof IPhantomTile){
if(this.checkHasConnection(stack, player, tile) && getStoredWorld(stack) == world){
((IPhantomTile)tile).setBoundPosition(getStoredPosition(stack));
if(tile instanceof TileEntityBase){
((TileEntityBase)tile).sendUpdate();
}
clearStorage(stack);
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
return true;
}
return false;
}
}
//Storing Connections
storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world);
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.stored.desc")));
}
return true;
}
public boolean checkHasConnection(ItemStack stack, EntityPlayer player, TileEntity tile){
if(getStoredPosition(stack) != null){
return true;
}
else{
if(tile instanceof IPhantomTile){
((IPhantomTile)tile).setBoundPosition(null);
}
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.unbound.desc")));
return false;
}
}
public static World getStoredWorld(ItemStack stack){ public static World getStoredWorld(ItemStack stack){
NBTTagCompound tag = stack.getTagCompound(); NBTTagCompound tag = stack.getTagCompound();
if(tag != null){ if(tag != null){
@ -118,6 +78,46 @@ public class ItemPhantomConnector extends ItemBase{
stack.setTagCompound(tag); stack.setTagCompound(tag);
} }
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing par7, float par8, float par9, float par10){
if(!world.isRemote){
//Passing Data to Phantoms
TileEntity tile = world.getTileEntity(pos);
if(tile != null){
//Passing to Phantom
if(tile instanceof IPhantomTile){
if(this.checkHasConnection(stack, player, tile) && getStoredWorld(stack) == world){
((IPhantomTile)tile).setBoundPosition(getStoredPosition(stack));
if(tile instanceof TileEntityBase){
((TileEntityBase)tile).sendUpdate();
}
clearStorage(stack);
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
return true;
}
return false;
}
}
//Storing Connections
storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world);
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.stored.desc")));
}
return true;
}
public boolean checkHasConnection(ItemStack stack, EntityPlayer player, TileEntity tile){
if(getStoredPosition(stack) != null){
return true;
}
else{
if(tile instanceof IPhantomTile){
((IPhantomTile)tile).setBoundPosition(null);
}
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.unbound.desc")));
return false;
}
}
@Override @Override
public boolean getShareTag(){ public boolean getShareTag(){
return true; return true;

View file

@ -54,6 +54,26 @@ public class ClientProxy implements IProxy{
private static Map<ItemStack, ResourceLocation> modelLocationsForRegistering = new HashMap<ItemStack, ResourceLocation>(); private static Map<ItemStack, ResourceLocation> modelLocationsForRegistering = new HashMap<ItemStack, ResourceLocation>();
private static Map<Item, ResourceLocation[]> modelVariantsForRegistering = new HashMap<Item, ResourceLocation[]>(); private static Map<Item, ResourceLocation[]> modelVariantsForRegistering = new HashMap<Item, ResourceLocation[]>();
private static void countBookletWords(){
bookletWordCount = 0;
bookletCharCount = 0;
for(IBookletEntry entry : ActuallyAdditionsAPI.bookletEntries){
for(IBookletChapter chapter : entry.getChapters()){
for(BookletPage page : chapter.getPages()){
if(page.getText() != null){
bookletWordCount += page.getText().split(" ").length;
bookletCharCount += page.getText().length();
}
}
bookletWordCount += chapter.getLocalizedName().split(" ").length;
bookletCharCount += chapter.getLocalizedName().length();
}
bookletWordCount += entry.getLocalizedName().split(" ").length;
bookletCharCount += entry.getLocalizedName().length();
}
}
@Override @Override
public void preInit(FMLPreInitializationEvent event){ public void preInit(FMLPreInitializationEvent event){
ModUtil.LOGGER.info("PreInitializing ClientProxy..."); ModUtil.LOGGER.info("PreInitializing ClientProxy...");
@ -99,26 +119,6 @@ public class ClientProxy implements IProxy{
ModelLoader.setCustomStateMapper(block, mapper); ModelLoader.setCustomStateMapper(block, mapper);
} }
private static void countBookletWords(){
bookletWordCount = 0;
bookletCharCount = 0;
for(IBookletEntry entry : ActuallyAdditionsAPI.bookletEntries){
for(IBookletChapter chapter : entry.getChapters()){
for(BookletPage page : chapter.getPages()){
if(page.getText() != null){
bookletWordCount += page.getText().split(" ").length;
bookletCharCount += page.getText().length();
}
}
bookletWordCount += chapter.getLocalizedName().split(" ").length;
bookletCharCount += chapter.getLocalizedName().length();
}
bookletWordCount += entry.getLocalizedName().split(" ").length;
bookletCharCount += entry.getLocalizedName().length();
}
}
@Override @Override
public void init(FMLInitializationEvent event){ public void init(FMLInitializationEvent event){
ModUtil.LOGGER.info("Initializing ClientProxy..."); ModUtil.LOGGER.info("Initializing ClientProxy...");

View file

@ -50,11 +50,6 @@ public class FuelHandler implements IFuelHandler{
addFuel(Item.getItemFromBlock(block), metadata, value); addFuel(Item.getItemFromBlock(block), metadata, value);
} }
@Override
public int getBurnTime(ItemStack fuel){
return getFuelValue(fuel);
}
private static int getFuelValue(ItemStack stack){ private static int getFuelValue(ItemStack stack){
if(stack != null && stack.getItem() != null){ if(stack != null && stack.getItem() != null){
Pair<Item, Integer> pair = Pair.of(stack.getItem(), stack.getItemDamage()); Pair<Item, Integer> pair = Pair.of(stack.getItem(), stack.getItemDamage());
@ -71,4 +66,9 @@ public class FuelHandler implements IFuelHandler{
} }
return 0; return 0;
} }
@Override
public int getBurnTime(ItemStack fuel){
return getFuelValue(fuel);
}
} }

View file

@ -51,6 +51,10 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
this.isDouble = false; this.isDouble = false;
} }
public static int getEnergyUse(boolean isDouble){
return isDouble ? 60 : 40;
}
@Override @Override
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){ public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
return this.storage.receiveEnergy(maxReceive, simulate); return this.storage.receiveEnergy(maxReceive, simulate);
@ -193,10 +197,6 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
return false; return false;
} }
public static int getEnergyUse(boolean isDouble){
return isDouble ? 60 : 40;
}
private int getMaxCrushTime(){ private int getMaxCrushTime(){
return this.isDouble ? 150 : 100; return this.isDouble ? 150 : 100;
} }

View file

@ -110,7 +110,9 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
@Override @Override
public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, net.minecraft.util.EnumFacing facing){ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, net.minecraft.util.EnumFacing facing){
return this.getCapability(capability, facing) != null; return this.getCapability(capability, facing) != null;
} @Override }
@Override
public int getInventoryStackLimit(){ public int getInventoryStackLimit(){
return 64; return 64;
} }
@ -131,7 +133,6 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
} }
@Override @Override
public void openInventory(EntityPlayer player){ public void openInventory(EntityPlayer player){

View file

@ -31,6 +31,10 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
super(2, "repairer"); super(2, "repairer");
} }
public static boolean canBeRepaired(ItemStack stack){
return stack != null && stack.getItem().isRepairable();
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("NextRepairTick", this.nextRepairTick); compound.setInteger("NextRepairTick", this.nextRepairTick);
@ -82,10 +86,6 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
return i == SLOT_INPUT; return i == SLOT_INPUT;
} }
public static boolean canBeRepaired(ItemStack stack){
return stack != null && stack.getItem().isRepairable();
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getEnergyScaled(int i){ public int getEnergyScaled(int i){
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored(); return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();

View file

@ -48,6 +48,20 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
this.capabilities = ForgeEventFactory.gatherCapabilities(this); this.capabilities = ForgeEventFactory.gatherCapabilities(this);
} }
public static int upgradeRange(int defaultRange, World world, BlockPos pos){
int newRange = defaultRange;
for(int i = 0; i < 3; i++){
Block block = PosUtil.getBlock(PosUtil.offset(pos, 0, 1+i, 0), world);
if(block == InitBlocks.blockPhantomBooster){
newRange = newRange*2;
}
else{
break;
}
}
return newRange;
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);
@ -114,20 +128,6 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
return false; return false;
} }
public static int upgradeRange(int defaultRange, World world, BlockPos pos){
int newRange = defaultRange;
for(int i = 0; i < 3; i++){
Block block = PosUtil.getBlock(PosUtil.offset(pos, 0, 1+i, 0), world);
if(block == InitBlocks.blockPhantomBooster){
newRange = newRange*2;
}
else{
break;
}
}
return newRange;
}
@Override @Override
public boolean hasBoundPosition(){ public boolean hasBoundPosition(){
if(this.boundPosition != null){ if(this.boundPosition != null){

View file

@ -17,6 +17,7 @@ import org.apache.logging.log4j.Logger;
import java.util.Locale; import java.util.Locale;
public class ModUtil{ public class ModUtil{
public static final String VERSION = "@VERSION@"; //build.gradle public static final String VERSION = "@VERSION@"; //build.gradle
public static final String MOD_ID = ActuallyAdditionsAPI.MOD_ID; public static final String MOD_ID = ActuallyAdditionsAPI.MOD_ID;